Compare commits
No commits in common. "fbbdbd43326925e69445080e82f38c8edc6e8dbf" and "f00bc1999459e021ea265a32a353e647af7040a7" have entirely different histories.
fbbdbd4332
...
f00bc19994
1 changed files with 0 additions and 44 deletions
44
requests.sh
44
requests.sh
|
@ -1,44 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
ACTION=$1
|
|
||||||
TOKEN=$2
|
|
||||||
ACTIONS=(login register rcvpw username)
|
|
||||||
|
|
||||||
print_help(){
|
|
||||||
echo "Usage: $0 ACTION [TOKEN]"
|
|
||||||
echo
|
|
||||||
echo "available actions:"
|
|
||||||
for el in "${ACTIONS[@]}"; do
|
|
||||||
echo - "$el"
|
|
||||||
done
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
print_help
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
case $ACTION in
|
|
||||||
"${ACTIONS[0]}") # login
|
|
||||||
echo "login action"
|
|
||||||
curl localhost:5050/api/login -X POST -d '{"username":"test","password":"test"}'
|
|
||||||
;;
|
|
||||||
"${ACTIONS[1]}") # register
|
|
||||||
echo "register action"
|
|
||||||
curl localhost:5050/api/register -X POST -d '{"username":"test","password":"test"}'
|
|
||||||
;;
|
|
||||||
"${ACTIONS[2]}") # reveice password
|
|
||||||
echo "rcv_pw action"
|
|
||||||
curl localhost:5050/api/protected/rcv_pw
|
|
||||||
;;
|
|
||||||
"${ACTIONS[3]}") # get current username
|
|
||||||
echo "get username action"
|
|
||||||
curl localhost:5050/api/username -X GET -H "Authorization: Bearer $TOKEN"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Action not available"
|
|
||||||
echo
|
|
||||||
print_help
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
Reference in a new issue