summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-09-08 05:28:28 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-09-08 05:28:28 +0200 |
commit | 936f186b6b767273fdc3c01f17311981c46e102c (patch) | |
tree | 624d6d9591df4cb869d1361f31c27c7a6a66350c /src/map/query/map_load.erl | |
parent | cbc16fc5033ae7bd49c053131ec842e8f3445041 (diff) |
Send "disconnected" cmd if user failed cred check.
This (currently) does not apply to the actual login page, but just to
any other action that requires being logged in.
Diffstat (limited to 'src/map/query/map_load.erl')
-rw-r--r-- | src/map/query/map_load.erl | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/map/query/map_load.erl b/src/map/query/map_load.erl index 3357c4f..ad6db17 100644 --- a/src/map/query/map_load.erl +++ b/src/map/query/map_load.erl @@ -48,16 +48,17 @@ parse_input (Req) -> map_id = MapID }. --spec authenticate_user (input()) -> 'ok'. +-spec authenticate_user (input()) -> ('ok' | 'error'). authenticate_user (Input) -> PlayerID = Input#input.player_id, SessionToken = Input#input.session_token, Player = shr_timed_cache:fetch(player_db, any, PlayerID), - shr_security:assert_identity(SessionToken, Player), - - ok. + case shr_security:credentials_match(SessionToken, Player) of + true -> ok; + _ -> error + end. -spec fetch_data (input()) -> query_state(). fetch_data (Input) -> @@ -83,11 +84,15 @@ generate_reply (QueryState) -> -spec handle (binary()) -> binary(). handle (Req) -> Input = parse_input(Req), - authenticate_user(Input), - shr_security:lock_queries(Input#input.player_id), - QueryState = fetch_data(Input), - shr_security:unlock_queries(Input#input.player_id), - generate_reply(QueryState). + case authenticate_user(Input) of + ok -> + shr_security:lock_queries(Input#input.player_id), + QueryState = fetch_data(Input), + shr_security:unlock_queries(Input#input.player_id), + generate_reply(QueryState); + + error -> jiffy:encode([shr_disconnected:generate()]) + end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |