Пример #1
0
 public function login()
 {
     Users::redirectIf(true);
     $nickname = Helper::post('nickname');
     $password = Helper::post('password');
     if (empty($nickname) || empty($password)) {
         Session::setFlash('danger', '', Translate::get('error.forms.missing.content'));
         Router::redirect('user.signin');
     }
     $users = Users::select()->addFields(['id', 'id_group', 'password', 'nickname', 'mail', 'user_key', 'firstname', 'lastname', 'avatar'])->where('nickname', $nickname)->andWhere('mail_check', '1')->orWhere('mail', $nickname)->get(0, 1);
     if (empty($users) || !password_verify($password, $users[0]->password)) {
         Session::setFlash('danger', '', Translate::get('user.error.login'));
         Router::redirect('user.signin');
     }
     $user = $users[0];
     $group = Groups::select()->where('id', $user->id_group)->get();
     if (empty($group)) {
         Session::setFlash('danger', '', 'Vous n\'êtes pas dans un groupe valide');
         Router::redirect('user.signin');
     }
     $group = $group[0];
     $br = new BinaryRight($group->auth_site);
     if (!$br->compare(Groups::getAuth('site', 'connection'))) {
         Session::setFlash('danger', '', 'Vous ne pouvez pas vous connecter !');
         Router::redirect('user.signin');
     }
     $user->connection_at = BaseModel::now();
     $user->save();
     Users::sessionSet($user);
     Session::setFlash('success', '', Translate::get('user.success.login'));
     Router::redirect('home.index');
 }
Пример #2
0
 private function isActive($type, $name, $auth)
 {
     $authCheck = 0;
     $auth = intval($auth);
     if (isset(Groups::$authorization[$type][$name])) {
         $authCheck = Groups::$authorization[$type][$name];
     }
     $br = new BinaryRight($auth);
     return $br->compare($authCheck);
 }
Пример #3
0
 public static function check($type, $auths)
 {
     $id_group = 0;
     if (Session::exists('member')) {
         $member = Session::get('member');
         $id_group = $member['id_group'];
     }
     $auth = self::$authorization[$type]['nothing_right'];
     if ($id_group != 0) {
         $group = Groups::select()->where('id', $id_group)->get();
         if (!empty($group)) {
             $field = "auth_" . $type;
             $auth = $group[0]->{$field};
         }
     }
     $br = new BinaryRight($auth);
     return $br->compare($auths);
 }