Example #1
0
 public function post_resetpassword()
 {
     $input = Input::all();
     $user = Console_User::find(Auth::user()->userid);
     if (Hash::check($input['oldpassword'], $user->password) && $input['password'] == $input['repassword']) {
         if (isset($input['username']) && $input['username'] != NULL) {
             $user->username = $input['username'];
         }
         $user->password = Hash::make($input['password']);
         $user->save();
     }
 }
Example #2
0
 public static function confirmUser($input, $id = 0)
 {
     if ($id != 0) {
         $user = Console_User::find($id);
         $user->username = $input['username'];
         $user->password = Hash::make($input['password']);
         $user->status = 1;
         $user->save();
         return true;
     } else {
         return false;
     }
 }
Example #3
0
 public static function loggedprofile()
 {
     $logged_user = Auth::user();
     $userInfo = Console_User::find($logged_user->userid)->userprofile;
     $data['profileid'] = $userInfo->profileid;
     $data['fullname'] = $userInfo->fullname;
     $data['icno'] = $userInfo->icno;
     $data['dob'] = $userInfo->dob;
     $data['emel'] = $userInfo->emel;
     $data['dob'] = $userInfo->dob;
     $data['address'] = $userInfo->address;
     $data['postcode'] = $userInfo->postcode;
     $data['town'] = $userInfo->town;
     $data['city'] = $userInfo->city;
     return json_encode($data);
 }
Example #4
0
 public function action_verifyupdate()
 {
     $input = Input::all();
     $rules = array('username' => 'required|exists:users', 'password' => 'required');
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         Redirect::to('confirmation/' . $input['key'])->with_errors($validation);
     }
     $existedUser = Console_User::where('validationkey', '=', $input['key'])->where('username', '=', $input['oldpassword'])->where('status', '=', 'Pending')->first(array('userid'));
     if ($existedUser) {
         $result = Console_User::confirmUser($input, $existedUser->userid);
     } else {
         return Redirect::to(URL::base());
     }
     echo $existedUser->userid;
     if ($result) {
         $profile = Console_Profile::where('userid', '=', $existedUser->userid)->first(array('emel'));
         try {
             $mailer = Message::to($profile->emel);
             $mailer->from('*****@*****.**', 'System Generate');
             $mailer->subject('User Registration Information');
             $mailer->body('view: plugins.emailAcc');
             $mailer->body->username = $input['username'];
             $mailer->body->password = $input['password'];
             $mailer->body->key = $input['key'];
             $mailer->html(true);
             $mailer->send();
         } catch (Exception $e) {
             Log::write('email', 'Message was not sent.');
             Log::write('email', 'Mailer error: ' . $e->getMessage());
         }
         $credentials = array('username' => $input['username'], 'password' => $input['password']);
         if (Auth::attempt($credentials)) {
             return Redirect::to('home/dashboard');
         } else {
             Session::flash('login_errors', 'Your email or password is invalid - please try again.');
             return Redirect::to(URL::base());
         }
     } else {
         return Redirect::to('confirmation/' . $input['key']);
     }
 }