diff options
Diffstat (limited to 'public/app/models/Access_model.php')
| -rw-r--r-- | public/app/models/Access_model.php | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/public/app/models/Access_model.php b/public/app/models/Access_model.php index 8d446dc..8a2e5ce 100644 --- a/public/app/models/Access_model.php +++ b/public/app/models/Access_model.php @@ -3,6 +3,7 @@ namespace app\models; use \Registry; +use app\extends\App_manager; use app\models\History_model; class Access_model @@ -148,36 +149,52 @@ class Access_model } - /** activate + /** activate_set_password * - * check if activation code is valid; - * if valid, set account active; + * activate user and set password * * @param $ticket (hex/MD5): activation code; * */ - public static function activate($ticket) + public static function activate_set_password($post, $password) { - $user = Registry::use('database')->query( - "SELECT * FROM user WHERE activation = :ticket", - [ 'ticket' => $ticket ] - )->getFirst(); - - // if no user with this activation code, return false - if ($user === false) return false; - - // remove activation code from user record - Registry::use('database')->runQuery( + // Update and set activate = true + $rowCount = Registry::use('database')->query( "UPDATE user - SET active = 1, `activation` = NULL - WHERE activation = :ticket", - [ 'ticket' => $ticket ] - ); + SET first_name = :first_name, + last_name = :last_name, + email = :email, + father_name = :father_name, + registration_number = :registration_number, + sector = :sector, + belonging_school = :belonging_school, + position = :position, + phone = :phone, + `password` = :password, + invitation = NULL, + active = :active + WHERE id = :id AND invitation = :invitation", + [ + ':first_name' => $post['first_name'], + ':last_name' => $post['last_name'], + ':email' => $post['email'], + ':father_name' => $post['father_name'], + ':registration_number' => $post['registration_number'], + ':sector' => $post['sector'], + ':belonging_school' => $post['belonging_school'], + ':position' => $post['position'], + ':phone' => $post['phone'], + ':password' => $password, + ':active' => 1, + ':id' => $post['id'], + ':invitation' => $post['invitation'] + ] + )->rowCount(); // update history - History_model::trackUserAccess($user['id'], TRACK_ACCOUNT, 'User Account Activated'); + History_model::trackUserAccess($post['id'], TRACK_ACCOUNT, 'User Account Activated'); - return true; + return $rowCount; } |
