Exemple #1
0
 /**
  * 重置密码
  * @return [type] [description]
  */
 public function reset_password()
 {
     $token = rq('token');
     $done = false;
     $errors = [];
     $expire = true;
     if (!$token) {
         abort(404);
     }
     $log = ILog::where('memo', $token)->first();
     if (!$log) {
         abort(404);
     }
     $at = Carbon::parse($log->at);
     $diff = $at->diffInHours(Carbon::now());
     if ($diff < 24) {
         $expire = false;
     }
     if (rq('reset') && Request::method() == 'POST' && !$expire) {
         $res = $this->reset($token, $log);
         if ($res['status']) {
             $done = true;
         } else {
             $errors = $res['errors'];
         }
     }
     return view('reset')->with(compact('token', 'log', 'errors', 'done', 'expire'));
 }
Exemple #2
0
 /**
  * 登入方法
  * @param null $input
  * @return array
  */
 public function login($input = null)
 {
     $input = $input ? $input : rq();
     if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) {
         $d = M('doctor');
         $d = $d->where('cust_id', $input['cust_id'])->first();
         if ($d) {
             log_him_in(['uid' => $d->id]);
             add_chara($input['user_type']);
             return ss();
         }
         return $d ? ss($d) : ee(2);
     }
     if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) {
         $input['password'] = hash_password($input['password']);
         $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password']));
         if ($user) {
             $lifetime = 6000;
             log_him_in(['username' => $user->username, 'uid' => $user->id], $lifetime);
             add_chara($input['user_type']);
             if ($input['user_type'] == 'employee') {
                 sess('permission', $user->permissions);
             } else {
                 sess('permission', []);
             }
             if ($input['user_type'] == 'agency') {
                 sess('org', $user->name);
                 sess('name_in_charge', $user->name_in_charge);
             }
             if ($input['user_type'] == 'department') {
                 sess('org', $user->hospital_name . ':' . $user->name);
             }
             if ($input['user_type'] == 'employee') {
                 sess('org', $user->name);
             }
             // 添加日志
             ILog::login($input['user_type'], $user);
             return ss($user);
         }
     } else {
         return ee(2);
     }
     return ee(2);
 }
Exemple #3
0
 public function auth($method = null, $data = null)
 {
     $action_type_id = 44;
     if ($method == 'reminder' && $data['type'] == 'agency') {
         $action_type_id = 45;
     }
     $user = $data['user'];
     // find or save
     ILog::add_log($action_type_id, -1, $user->id, $data['hash']);
 }