예제 #1
0
 public function action_verifyupdate()
 {
     $input = Input::all();
     $rules = array('username' => 'required|exists:users', 'password' => 'required');
     // $validation = Validator::make($input, $rules);
     // if( $validation->fails() ) {
     //     return Redirect::to('home')->with_errors($validation);
     // }
     $existedUser = Admin_User::where('validationkey', '=', $input['key'])->where('username', '=', $input['oldpassword'])->where('status', '=', 'Pending')->first(array('userid'));
     $result = Admin_User::confirmUser($input, $existedUser->userid);
     if ($result) {
         $emel = Admin_UserProfile::find($existedUser->userid)->emel;
         try {
             $mailer = Message::to($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('eis/dashboard');
         } else {
             Session::flash('login_errors', 'Your email or password is invalid - please try again.');
             return Redirect::to(URL::base());
         }
     } else {
         return Redirect::to('home/confirmation/' . $input['key']);
     }
 }
예제 #2
0
 public function post_profile()
 {
     $input = Input::all();
     // $validation = Admin_UserProfile::validate($input);
     // if( $validation->fails() ) {
     //     return Redirect::to('user/profile')->with_errors($validation)->with_input();
     // }
     // $extension = File::extension($input['photo']['name']);
     // $directory = path('public').'avatar/'.sha1(Auth::user()->userid);
     // $filename = sha1(Auth::user()->userid.time()).".{$extension}";
     $profile = Admin_UserProfile::find(Auth::user()->userid);
     // if($input['photo']['size'] != null){
     //     $upload_success = Input::upload('photo', $directory, $filename);
     //     if( $upload_success ) {
     //         while(is_file('public/'.$profile->imgpath) == TRUE)
     //         {
     //             chmod('public/'.$profile->imgpath, 0666);
     //             unlink('public/'.$profile->imgpath);
     //         }
     //         $profile->imgpath = 'avatar/'.sha1(Auth::user()->userid).'/'.$filename;
     //     }
     // }
     $profile->fullname = $input['fullname'];
     $profile->dob = date('Y-m-d', strtotime($input['dob']));
     $profile->address = $input['address'];
     $profile->postcode = $input['postcode'];
     $profile->emel = $input['emel'];
     $profile->town = $input['town'];
     $profile->city = $input['city'];
     $profile->icno = $input['icno'];
     $profile->save();
     $profile = Admin_UserProfile::loggedprofile();
     return $profile;
 }