| 1 | module main |
| 2 | |
| 3 | pub fn (mut app App) edit_user(user_id int, delete_tokens bool, is_blocked bool, is_admin bool) ! { |
| 4 | if is_admin { |
| 5 | app.add_admin(user_id)! |
| 6 | } else { |
| 7 | app.remove_admin(user_id)! |
| 8 | } |
| 9 | |
| 10 | if is_blocked { |
| 11 | app.block_user(user_id)! |
| 12 | } else { |
| 13 | app.unblock_user(user_id)! |
| 14 | } |
| 15 | |
| 16 | if delete_tokens { |
| 17 | app.delete_tokens(user_id)! |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | pub fn (mut app App) block_user(user_id int) ! { |
| 22 | app.set_user_block_status(user_id, true)! |
| 23 | } |
| 24 | |
| 25 | pub fn (mut app App) unblock_user(user_id int) ! { |
| 26 | app.set_user_block_status(user_id, false)! |
| 27 | } |
| 28 | |
| 29 | pub fn (mut app App) add_admin(user_id int) ! { |
| 30 | app.set_user_admin_status(user_id, true)! |
| 31 | } |
| 32 | |
| 33 | pub fn (mut app App) remove_admin(user_id int) ! { |
| 34 | app.set_user_admin_status(user_id, false)! |
| 35 | } |
| 36 | |
| 37 | pub fn (mut app App) update_gitly_settings(oauth_client_id string, oauth_client_secret string, tree_folder_size_enabled bool) ! { |
| 38 | app.update_settings(oauth_client_id, oauth_client_secret, tree_folder_size_enabled)! |
| 39 | |
| 40 | app.load_settings() |
| 41 | } |
| 42 | |
| 43 | fn (mut ctx Context) is_admin() bool { |
| 44 | return ctx.logged_in && ctx.user.is_admin |
| 45 | } |
| 46 | |