diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-06-01 03:33:18 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-06-01 03:33:18 +0300 |
| commit | 864fbb806621c8167c49f7449486fbc3bdaca1a6 (patch) | |
| tree | 1b5b5933dbb184b130c248d3281e709bd6286c5d /public/app/controllers/Auth.php | |
| parent | 950798a91c0bed3f2d6e53182b0cff49f07eff0c (diff) | |
| download | gyraf1gov-864fbb806621c8167c49f7449486fbc3bdaca1a6.tar.gz gyraf1gov-864fbb806621c8167c49f7449486fbc3bdaca1a6.tar.bz2 gyraf1gov-864fbb806621c8167c49f7449486fbc3bdaca1a6.zip | |
user update; user petitions copy; fixed docker performance issues
Diffstat (limited to 'public/app/controllers/Auth.php')
| -rw-r--r-- | public/app/controllers/Auth.php | 82 |
1 files changed, 77 insertions, 5 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php index 9f440ed..cbf4d19 100644 --- a/public/app/controllers/Auth.php +++ b/public/app/controllers/Auth.php @@ -20,7 +20,7 @@ use app\extends\SendMail_service; */ class Auth { - /** login + /** AJAX POST: login * * checks visitor's credentials; * if valid, authenticates user @@ -98,7 +98,7 @@ class Auth { } - /** activate + /** AJAX POST: activate * resolves call POST:/account/activate * * @param void : all parametres passed via request->POST @@ -118,20 +118,50 @@ class Auth { if ($check != 0) { Render::json([ 'title' => ACCOUNT_ACTIVATED_TITLE, - 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' + 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' ]); } else { Render::json([ 'title' => NOT_VALID_ACTIVATION_TITLE, - 'message' => NOT_VALID_ACTIVATION_MESSAGE + 'message' => NOT_VALID_ACTIVATION_MESSAGE ]); } } - /** invitation + + /** AJAX POST: update_user + * + * resolves call POST:/user/update_properties; + * updates user's proiperties with POSTed data + * + * @param void : all parametres passed via request->POST + */ + public static function update_user() + { + $req = Registry::get('REQUEST'); + $manager = new App_manager(); + ; + // print_r($req->POST); die(); + + // ask model to update user; get user-id from user-manager + $check = Access_model::update_user( + $req->POST, + $manager->getUserToken()->getUser()->getID() + ); + + // TODO: message for user updating properties + Render::json([ + 'title' => ACCOUNT_ACTIVATED_TITLE, + 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' + ]); + + } + + + /** SERVE FORM: invitation * * setups and renders the form for a certain invitation * @@ -188,6 +218,48 @@ class Auth { } + /** SERVE FORM: update_form + * + * renders a form with all user's properties + * + * NOTE: + * after form is submited, client shall call Auth::update_user() + * + */ + public static function update_form() + { + $user = json_decode(json_encode(self::user_data(), JSON_UNESCAPED_UNICODE)); + + // format form_setup to a json array + $form_setup = json_decode(json_encode(USER_PROPERTIES_FORM, JSON_UNESCAPED_UNICODE)); + + // get $key of position item inside the form_setup->form array + for( $i=0; $i < sizeof($form_setup->form) ; $i++ ) { + if ($form_setup->form[$i]->name == 'position') { $key = $i; } + } + + // prepare gendered options to position field + $positions = ($user->prefix != 'η') + ? GENDERED_POSITIONS['he'] + : GENDERED_POSITIONS['she']; + $gendered_position = json_decode( json_encode( $positions, JSON_UNESCAPED_UNICODE )); + $form_setup->form[$key]->options = $gendered_position; + + // attach default values + $form_setup->defaults = $user; + + // get Form's HTML and Jsvascript + $form = JsonToForm::json_form($form_setup, [ + // pass invitation identity for security + ['name' => 'id', 'value' => $user->id] + ]); // print_r($form_setup); die(); + + Render::view('user/update_properties', [ + 'form' => $form + ]); + } + + /** is_connected * checks if the user is connected * |
