Ejemplo n.º 1
0
 public static function checkPermission()
 {
     $userInfo = Session::get('user');
     $uri = new Permission();
     $currentRoute = Route::getFacadeRoot()->current()->uri();
     if (Cache::has('user')) {
         $user = Cache::get('user');
         $permission = $user['permission'];
         $ck = in_array($userInfo['role_id'] . '|' . $currentRoute, $permission);
     } else {
         $ck = $uri->where('name', $userInfo['role_id'] . '|' . $currentRoute)->count();
     }
     if ($ck > 0 || $userInfo['role_id'] == 1) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 public function storeUserType(Request $request)
 {
     $rules = ['name' => 'required|min:6', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6', 'phone_number' => 'required', 'age' => 'required|numeric', 'gender' => 'required'];
     $messages = ['name.required' => 'Please Enter Your Name.', 'email.required' => 'Please Enter Email Address.', 'password.required' => 'Please enter your password', 'age.required' => 'Please enter your age', 'gender.required' => 'Please Check Your Gender', 'phone_number.required' => 'Please Enter Your Phone Number'];
     $validator = Validator::make($request->all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $confirmation_code = str_random(30);
     //To get User Type
     $routeType = Route::getFacadeRoot()->current()->uri();
     if ($routeType == 'saveTeacherProfile') {
         $userType = 'teacher';
     } else {
         $userType = 'admin';
     }
     User::create(['name' => $request->input('name'), 'email' => $request->input('email'), 'gender' => $request->input('gender'), 'age' => $request->input('age'), 'password' => bcrypt($request->input['password']), 'confirmation_code' => $confirmation_code, 'phone_number' => $request->input('phone_number'), 'user_type' => $userType]);
     $data = array('confirmation_code' => $confirmation_code, 'name' => Input::get('name'));
     Mail::send('email.verify', $data, function ($message) {
         $message->to(Input::get('email'), Input::get('name'))->subject('Verify your email address');
     });
     Session::flash('success', 'Sir,Thanks for signing up! Please check your email.');
     return Redirect::to('student-registration');
 }
 /**
  * Bind data to the view.
  *
  * @param \Illuminate\Contracts\View\View $view View object
  *
  * @return void
  */
 public function compose(\Illuminate\Contracts\View\View $view)
 {
     $view->with('currentRoute', $this->route->getFacadeRoot()->currentRouteName());
 }
Ejemplo n.º 4
0
 /**
  * Get a default route value, if any is available
  *
  * @return Registrar|null A default route value or Null if no default value is available
  */
 public function getDefaultRoute()
 {
     return Route::getFacadeRoot();
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $this->router = \Illuminate\Support\Facades\Route::getFacadeRoot();
 }
Ejemplo n.º 6
0
 public function loginPost(Request $request)
 {
     //validate input
     $v = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
     //recaptcha implementation
     //TODO after 5 attempt show recaptcha
     //$recaptcha = new \ReCaptcha\ReCaptcha(Setting::getSetting('recaptchasecret'));
     //$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     if ($v->fails()) {
         $errors = $v->errors();
         $return['status'] = false;
         $return['errors'] = $errors;
     }
     $userdata = array('email' => $request->get('email'), 'password' => $request->get('password'));
     $remember = false;
     if ($request->has('remember_me') && $request->get('remember_me') == 1) {
         $remember = true;
     }
     if (Auth::attempt($userdata, $remember)) {
         $currentPath = Route::getFacadeRoot()->current()->uri();
         $return['status'] = true;
         $return['url'] = url($currentPath);
     } else {
         $return['status'] = false;
         $return['errors'] = ['general' => ['Please check your email and/or password or register']];
     }
     return $return;
 }