Create WorkSpace Requester account
WorkFusion WorkSpace (WS) application has two user roles:
- Worker
- Requester
The worker role is the most widely used one, and such users can be created via self-registration. Requester accounts can be created only by an SQL query to the WS database.
Below is the Bash script to create a Requester account:
#!/bin/bash
if [[ -z $3 ]]; then
echo Usage: $0 username 3_symbol password
echo Example: $0 johnsmith AHR phrase4Password
exit 1
fi
uid=`uuidgen | sed s/-//g`
PASSSBX=`uuidgen | sed s/-//g`
PASSPROD=`uuidgen | sed s/-//g`
UIDP="${uid^^}"
PASSP="${PASSPROD^^}"
PASSS="${PASSSBX^^}"
NAME="${1^^}"
SHRT="${2^^}"
PROD="PROD"
SDBX="SBX"
PASSWORD=$3
echo "Access key: $SHRT$UIDP"
echo "Secret key production: $SHRT$PROD$PASSP"
echo "Secret key sandbox : $SHRT$SDBX$PASSS"
echo "Password : $PASSWORD"
ADDACCOUNT="INSERT INTO account(
id, username, password, access_key_id, access_key, first_name,
last_name, amount, currency_code, formatted_price, country, organization,
currency_symbol, expiration_time, token, last_updated_by, creation_time,
update_time, vid, email, timezone, cpr_id, roles)
VALUES (nextval('account_id_seq'), '$1', crypt('$PASSWORD', gen_salt('bf', 10)), '$1', '$SHRT$UIDP', '$1', '', 20000.00, 'USD', '\$20000,00', 'US', '$NAME', '$', '2020-03-03', null, null, now(), null, '$SHRT$PROD$PASSP', '$1', 'GMT', null, Array['ROLE_REQUESTER'::user_role]);"
ADDREQUESTER="INSERT INTO requester(
id, reserved_amount)
VALUES (currval('account_id_seq'), 0.00);"
ADDACCOUNTSBX=`echo $ADDACCOUNT | sed s/$SHRT$PROD$PASSP/$SHRT$SDBX$PASSS/`
psql -h "127.0.0.1" -U postgresadmin -A -t -d virtualizer -c "$ADDACCOUNT $ADDREQUESTER"
psql -h "127.0.0.1" -U postgresadmin -A -t -d virtualizer_sandbox -c "$ADDACCOUNTSBX $ADDREQUESTER"
echo Done.
To execute the script, run the command below as wf_user:
./scriptname $username $NME $password
usernameis the desired Requester username.passwordis the desired Requester password.NMErepresents the three symbols required for the generator.
Usage example:
./script johnsmith AHR phrase4Password