ocw/webroot/api/login.shs

19 lines
614 B
Bash

#!/bin/bash
source code/common.sh
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' ]]; then
login "${post_data[login]}" "${post_data[password]}"
status=$?
if ! account_verified "${post_data[login]}"; then
status=-2
reason="Account not verified"
fi
if [[ $status == 0 ]]; then
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 "success"
else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args "$status" "$reason"
fi
else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "Send me some credentials, dammit!"
fi