Skip to content

Commit 298802d

Browse files
committed
feat: sign user out of all sessions
1 parent 55e6620 commit 298802d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

bin/signout.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
SCRIPT_DIR=$(builtin cd "$(dirname ${BASH_SOURCE[0]})" && builtin pwd)
5+
6+
source "${SCRIPT_DIR}/common.sh"
7+
8+
__usage="
9+
Usage: $(basename $0) USER
10+
11+
Arguments:
12+
USER The account in $DOMAIN (sans domain) to sign out from all sessions
13+
"
14+
15+
# print usage for -? or -h or --help
16+
if [[ "$#" -lt 1 || "$1" =~ ^(-\?|-h|--help)$ ]]; then
17+
echo "$__usage"
18+
exit 0
19+
fi
20+
21+
# the full account name to signout
22+
ACCOUNT="$1@$DOMAIN"
23+
24+
# verify $ACCOUNT exists before continuing
25+
if ! user_exists $ACCOUNT; then
26+
echo_ts "Account $ACCOUNT does not exist, stopping"
27+
exit 1
28+
else
29+
echo_ts "Account $ACCOUNT exists, continuing..."
30+
fi
31+
32+
echo_ts "Signing out $ACCOUNT from all active sessions..."
33+
34+
gam user $ACCOUNT signout

0 commit comments

Comments
 (0)