+ login API
This commit is contained in:
parent
875b295dc8
commit
c9ccf121ab
11
webroot/api/login.shs
Normal file
11
webroot/api/login.shs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then
|
||||||
|
login ${post_data[login]} ${post_data[password]}
|
||||||
|
status=$?
|
||||||
|
if [[ $status == 0 ]]; then
|
||||||
|
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args 200 "success"
|
||||||
|
elif [[ $status == 1 && $reason != '' ]]; then
|
||||||
|
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "$reason"
|
||||||
|
fi
|
||||||
|
fi
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then
|
|
||||||
login ${post_data[login]} ${post_data[password]}
|
|
||||||
status=$?
|
|
||||||
if [[ $status == 0 ]]; then
|
|
||||||
echo ${get_data[r]} > /dev/stderr
|
|
||||||
if [[ ${get_data[r]} == '' ]]; then
|
|
||||||
meta[redirect]='/'
|
|
||||||
else
|
|
||||||
meta[redirect]="$(echo ${get_data[r]} | sed -s 's/<//g;s/___/?/')"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
source templates/head.sh
|
|
||||||
|
|
||||||
if [[ $status == 1 && $reason != '' ]]; then
|
|
||||||
echo $reason
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "<h1>Log in...</h1>
|
|
||||||
<form method='post'>
|
|
||||||
<label for='login'>Login:</label>
|
|
||||||
<input type='text' name='login'><br>
|
|
||||||
<label for='password'>Password:</label>
|
|
||||||
<input type='password' name='password'><br>
|
|
||||||
<input type='submit' value='Login'>
|
|
||||||
</form>
|
|
||||||
(please make sure that you're connecting over SSL)"
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
logout
|
|
||||||
meta[redirect]='/'
|
|
||||||
source templates/head.sh
|
|
||||||
|
|
||||||
echo "Logged out successully. Redirecting.."
|
|
Loading…
Reference in a new issue