#!/bin/bash

SERVER=127.0.0.1
PORT=80
HTTP=http
TOKEN=

function get_token(){
    TOKEN=$(curl -X POST -s -k -i -d "account=$1&password=edoc2" ${HTTP}://${SERVER}:${PORT}/api/auth/login | grep token | head -n 1 | awk -F '[=|;]' '{print $2}')
    echo "$1: $TOKEN"
}


function main(){
    for i in `cat user1000.csv`; do
        get_token $i
    done
}

main
