public function signin() { $email = Request::getParam('email'); $pass = Request::getParam('pass'); $remember = !empty(Request::getParam('remember')); $admin = !empty(Request::getParam('admin')); $user = UserModel::first('email = ?', [$email]); if ($user && Hash::match($pass, $user->pass)) { $permission = PermissionModel::first('user_id = ?', [$user->id])->permission; // check permision type for the user if ($admin && $permission != 'admin') { Session::flash("msg", '<li><span class="msg-error">Error: </span> Ooops!... No admin found (wrong email or password ) , let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); exit; } else { if (!$admin && $permission == 'admin') { Session::flash("msg", '<li><span class="msg-error">Error: </span> Ooops!... No User found (wrong email or password ) , let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); exit; } } $u = new User($user->hash); $u->login($remember); redirect(route('user.profile')); } else { Session::flash("msg", '<li><span class="msg-warning">Warning: </span> Ooops!... wrong email or password, let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); } }
function control($next) { $user_data = Request::getALlParams(); Validation::check($user_data, ['name' => ['required' => true, 'unicode_space' => true, 'min' => 2, 'title' => 'Name'], 'email' => ['field' => 'email', 'title' => 'E-mail'], 'pass' => ['required' => true, 'field' => 'nr_password', 'min' => 8, 'title' => 'Password'], 'newpass' => ['field' => 'nr_password', 'min' => 8, 'title' => 'New Password'], 'repass' => ['matches' => 'newpass', 'title' => 'Re-password'], 'tel' => ['field' => 'phone', 'title' => 'Telephone'], 'mobile' => ['field' => 'phone', 'title' => 'Mobile']]); $avatar = Request::getFile('avatar'); $str = ''; if (Validation::passed()) { // grapping the current user data $user = User::getData(); // password check if (Hash::match(Request::getParam('pass'), $user->pass)) { // if the avatar is set it will be tested $avatarFlag = true; if (!empty($avatar)) { $avatarFlag = $avatar->size <= 100000 && scanImageToPng($avatar->tmp_name, Url::resource("images/{$avatar->name}")); if (!$avatarFlag) { $str .= '<li><span class="msg-error" >Error: </span> The Avatar must be an image and less that 10 MB</li>'; } } //if the email changed it will be tested $email = Request::getParam('email'); $emailFlag = true; if ($user->email != $email && UserModel::findBy(['email' => $email])) { $emailFlag = false; $str .= '<li><span class="msg-error" >Error: </span> The Email already Exists choose another one</li>'; } //if the telephone changed it will be tested $tel = Request::getParam('tel'); $telFlag = true; if ($user->tel != $tel && UserModel::findBy(['tel' => $tel])) { $telFlag = false; $str .= '<li><span class="msg-error" >Error: </span> The Telephone already Exists choose another one</li>'; } //if the mobile changed it will be tested $mobile = Request::getParam('mobile'); $mobileFlag = true; if ($user->mobile != $mobile && UserModel::findBy(['mobile' => $mobile])) { $mobileFlag = false; $str .= '<li><span class="msg-error" >Error: </span> The Mobile already Exists choose another one</li>'; } // if the avatar test and the email test and the mobile test and the telephone test are passed, // move to next step if ($avatarFlag && $emailFlag && $mobileFlag && $telFlag) { return $next(); } } else { $str .= '<li><span class="msg-error" >Error: </span> The Password doesn\'t match the current one</li>'; } } $msgs = Validation::getAllErrorMsgs(); if (count($msgs)) { foreach ($msgs as $msg) { $str .= '<li><span class="msg-error" >Error: </span> ' . $msg . '</li>'; } } Session::flash('msg', $str); Session::flash('data', $user_data); goBack(); }
function control($next) { $user_data = Request::getALlParams(); Validation::check($user_data, ['name' => ['required' => true, 'unicode_space' => true, 'min' => 2, 'title' => 'Name'], 'email' => ['required' => true, 'field' => 'email', 'unique' => 'users', 'title' => 'E-mail'], 'pass' => ['required' => true, 'field' => 'nr_password', 'min' => 8, 'title' => 'Password'], 'tel' => ['required' => true, 'field' => 'phone', 'unique' => 'users', 'title' => 'Telephone'], 'mobile' => ['required' => true, 'field' => 'phone', 'unique' => 'users', 'title' => 'Mobile'], 'repass' => ['required' => true, 'matches' => 'pass', 'title' => 'Re-password']]); if (Validation::passed()) { return $next(); } else { $msgs = Validation::getAllErrorMsgs(); $str = ''; foreach ($msgs as $msg) { $str .= '<li><span class="msg-error" >Error: </span> ' . $msg . '</li>'; } Session::flash('msg', $str); Session::flash('data', $user_data); goBack(); } }
function control($next) { $complain = Request::getALlParams(); Validation::check($complain, ['description' => ['required' => true, 'title' => 'Complain']]); if (Validation::passed()) { return $next(); } else { $msgs = Validation::getAllErrorMsgs(); $str = ''; foreach ($msgs as $msg) { $str .= '<li><span class="msg-error" >Error: </span> ' . $msg . '</li>'; } Session::flash('msg', $str); Session::flash('data', $complain); goBack(); } }