Example #1
0
 public function _edit()
 {
     $this->user = ZingUser::find($this->params['id']);
     if ($this->request->is_post()) {
         if (is_empty($this->params['user']['password'])) {
             unset($this->params['user']['password']);
             unset($this->params['user']['password_confirmation']);
         }
         $this->user->set_public_attributes($this->params['user']);
         if ($this->user->is_valid()) {
             $this->user->save();
             $this->flash('success', 'User ' . $this->user->get_username() . ' updated successfully');
             $this->redirect_to($this->admin_users_url());
         }
     }
 }
Example #2
0
 public function _login()
 {
     if ($this->is_admin_logged_in()) {
         $this->redirect_to_admin_dashboard();
     } else {
         if ($this->request->is_post()) {
             $user = \zing\cms\auth\ZingUser::authenticate_by_username($this->params['username'], $this->params['password']);
             if ($user) {
                 $this->log_in_admin($user);
                 $this->flash('success', 'Login successful');
                 $this->redirect_to_admin_dashboard();
             } else {
                 $this->flash_now('error', 'Invalid username/password');
             }
         }
     }
 }
Example #3
0
 public function logged_in_admin()
 {
     if ($this->admin_user === false) {
         $id = $this->logged_in_admin_id();
         if ($id) {
             $this->admin_user = \zing\cms\auth\ZingUser::find($id);
         } else {
             $this->admin_user = null;
         }
     }
     return $this->admin_user;
 }