diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-06-24 16:01:06 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-06-24 16:01:06 -0400 |
commit | e9460ea44fe7c11dc6d7d668ca9cd1b36418f097 (patch) | |
tree | a6f5a0c8f7380a8e242dd1e2782458cd66c7770e | |
parent | 3d7696972f5025be9612f87c0fe4203e0859641e (diff) | |
download | levitating-e9460ea44fe7c11dc6d7d668ca9cd1b36418f097.tar.gz levitating-e9460ea44fe7c11dc6d7d668ca9cd1b36418f097.zip |
Player tokens can now be set via web interface.
-rw-r--r-- | captain/db.f90 | 25 | ||||
-rw-r--r-- | captain/web.f90 | 19 |
2 files changed, 42 insertions, 2 deletions
diff --git a/captain/db.f90 b/captain/db.f90 index b789280..315bd10 100644 --- a/captain/db.f90 +++ b/captain/db.f90 @@ -146,6 +146,31 @@ contains end subroutine update_player_token_db + function player_has_token_db(name) + implicit none + + character(*), intent(in)::name + logical::player_has_token_db + type(sqlite3_stmt)::stmt + + character(128)::tk + + player_has_token_db = .false. + + if(stmt%prepare(db, "SELECT token FROM players WHERE name=?") == SQLITE_OK) then + if(stmt%bind_text(1, name) == SQLITE_OK ) then + if(stmt%step() == SQLITE_ROW) then + call stmt%column_text(0, tk) + player_has_token_db = (trim(tk) /= "None") + end if + end if + end if + call stmt%finalize() + + + end function player_has_token_db + + subroutine remove_player_db(name) implicit none diff --git a/captain/web.f90 b/captain/web.f90 index c18848e..9817775 100644 --- a/captain/web.f90 +++ b/captain/web.f90 @@ -609,7 +609,17 @@ contains end if ! Token assignment - res = trim(res)//new_line(' ')//"<h3>Security</h3>"//new_line(' ')// & + res = trim(res)//new_line(' ')//"<h3>Security</h3>"//new_line(' ')//"<p>" + + if(player_has_token_db(trim(player_name))) then + res = trim(res)//"Player currently has a token assigned." + else + res = trim(res)//"<em>Player is insecure! Please assign a token!</em>" + end if + + res = trim(res)//"</p>" + + res = trim(res)//new_line(' ')// & '<form action="assign_token.html" method="POST">'//new_line(' ')// & '<label for="token">Token:</label>'// & '<input name="token" id="token" />'//new_line(' ')// & @@ -1016,7 +1026,7 @@ contains end function request_templated function handle_post(req) result(resp) - use captain_db, only: add_player_db, add_group_db + use captain_db, only: add_player_db, add_group_db, update_player_token_db use page_template use config, only: template_filepath use logging @@ -1055,6 +1065,11 @@ contains call add_player_db(posted%get_value("name")) call page%assign('destination', 'players.html') + else if(trim(second) == "assign_token.html") then + + call update_player_token_db(posted%get_value("player"), posted%get_value("token")) + call page%assign('destination', "players/"//posted%get_value("player")//".html") + end if else if(trim(category) == "groups") then |