示例#1
0
 public function postLogin(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|exists:users,email', 'password' => 'required|min:6|max:12|exists:users,password']);
     $user = \App\users::All();
     $useremail = $request->input('email');
     $userpassword = $request->input('password');
     foreach ($user as $user) {
         $ckuser = $user->email;
         $ckpass = $user->password;
         $name = $user->name;
         $id = $user->id;
         $status = $user->status;
         if ($useremail == $ckuser && $userpassword == $ckpass) {
             Session::set('id', $id);
             Session::set('email', $ckuser);
             Session::set('status', $status);
             Session::set('name', $name);
             Session::set('logout', "logout");
             if (Session::get('status') == 1) {
                 return redirect('/admin');
             } else {
                 return redirect('/index/' . $name);
             }
         }
     }
 }
示例#2
0
 public function roleChange()
 {
     $user = \App\users::find(session('user')->userid);
     $user->roleid = 2;
     $user->save();
     session(['user' => $user]);
     return redirect('/dashboard/sell');
 }
示例#3
0
 public function postDeleteid($id)
 {
     $user = \App\users::find($id);
     $st = \App\statususers::where('username', $user->name)->get();
     $status = \App\statususers::findOrNew($st[0]['id']);
     $status->delete();
     $user->delete();
     return redirect('/admin');
 }
示例#4
0
 public function postPass()
 {
     $validator = Validator::make(Input::all(), array("oldPass" => "required", "newPass" => "required|min:6", "confPass" => "required|same:newPass"));
     if ($validator->passes()) {
         $password = Input::get('oldPass');
         $haspass = Auth::user()->password;
         if (Hash::check($password, $haspass)) {
             $chpass = users::find(Auth::user()->id);
             $chpass->password = Hash::make(Input::get('newPass'));
             $chpass->save();
             return Redirect::to("setting/password")->with('setting_success', 'Your password was updated.');
         } else {
             return Redirect::to('setting/password')->with('oldpass_fail', 'wrong');
         }
     } else {
         return Redirect::to('/setting/password')->withErrors($validator)->withInput();
     }
 }
示例#5
0
 public function getRegister()
 {
     $validator = Validator::make(Input::all(), array("firstname" => "required", "lastname" => "required", "email" => "required|email|unique:users,email", "password" => "required|min:6", "registerAs" => "required"));
     // 2a. jika semua validasi terpenuhi simpan ke database
     if ($validator->passes()) {
         $userr = new users();
         $userr->Namadepan = Input::get('firstname');
         $userr->Namabelakang = Input::get('lastname');
         $userr->email = Input::get('email');
         $userr->password = Hash::make(Input::get('password'));
         $userr->remember_token = Input::get('_token');
         $userr->user_level = Input::get('registerAs');
         $userr->state = Input::get('provinsi');
         $userr->save();
         return Redirect::to("/register")->with('register_success', 'Thank you, register successfully');
     } else {
         return Redirect::to('/register')->withErrors($validator)->withInput();
     }
 }
示例#6
0
 public function updatePassword(PasswordUpdateRequest $request)
 {
     $user = \App\users::find(session('user')->userid);
     if ($user->password == $request->input('oldpassword')) {
         if ($request->input('oldpassword') != $request->input('password')) {
             $user->password = $request->input('oldpassword');
             $user->save();
             \Session::flash('message', 'Password changed Successfully!');
             \Session::flash('type', 'success');
             return view('user.password');
         } else {
             \Session::flash('message', 'New password and Old password cannot be the same');
             \Session::flash('type', 'danger');
             return view('user.password');
         }
     } else {
         \Session::flash('message', 'Old Password is not valid');
         \Session::flash('type', 'danger');
         return view('user.password');
     }
 }