예제 #1
0
 public function doRegister()
 {
     // validate the info, create rules for the inputs
     $rules = array('nip' => 'required', 'password' => 'required', 'password_conf' => 'required|same:password');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('registration')->withErrors($validator);
         // send back all errors to the login form
     } else {
         //if user not found create it
         $user = User::where('nip', '=', Input::get('username'))->first();
         if (is_null($user)) {
             //cek di bagian master pegawai
             $masterPegawai = MasterPegawai::where('nip', '=', Input::get('nip'))->first();
             if (!is_null($masterPegawai)) {
                 // Validate, then create if valid
                 $newUser = new User();
                 $newUser->nip = Input::get('nip');
                 $newUser->username = Input::get('nip');
                 $newUser->password = Hash::make(Input::get('password'));
                 if ($newUser->save()) {
                     //attach to user roles
                     $newUser->group()->attach(2);
                     return View::make('employeemenpan::auth.successregistration');
                 }
             } else {
                 //                    dd('error 303');
                 return Redirect::to('registration')->with('message', 'nip tidak ditemukan dalam siAsik');
             }
         } else {
             //                dd('error 403');
             return Redirect::to('registration')->with('message', 'nip sudah terdaftar dalam siMSDM-TBK ');
         }
     }
 }
예제 #2
0
 public function changePassword()
 {
     $rules = array('newpassword' => array('required', 'Confirmed'), 'newpassword_confirmation' => array('required'));
     if (Input::has('newpassword')) {
         $v = Validator::make(Input::all(), $rules);
         if ($v->passes()) {
             # code for validation success!
             $user = Auth::user();
             $dataUser = User::where('username', '=', $user->nip)->first();
             $dataUser->password = Hash::make(Input::get('newpassword'));
             $dataUser->save();
             return Redirect::to('user/changepassword')->with('message', 'password berhasil di ubah');
         } else {
             # code for validation failure
             $messages = $v->messages();
             return Redirect::to('user/changepassword')->withErrors($messages);
         }
     }
     $this->layout->content = View::make('employeemenpan::usersetting.changepassword');
 }