Exemple #1
0
 public static function ecard(Request $request)
 {
     $valid = Validator::make($request->all(), self::$ecard_rule);
     if ($valid->fails()) {
         return false;
     }
     $data = ['account' => $request->input('account'), 'password' => $request->input('password'), 'type' => 'ecard', 'status' => 'available'];
     $result = [];
     $admin_auto_sys_usr_exist = DB::connection('sso')->table("x00tpseudo_uid_")->select(DB::raw("convert_from(decrypt(decode(password,'hex'),'bsofafrfktr','aes'), 'utf-8') as rp, staff_cd"))->where("staff_cd", $request->input('account'))->first();
     //var_dump($admin_auto_sys_usr_exist);
     if (Auth::attempt($data)) {
         $result['status'] = 1;
     } else {
         if ($admin_auto_sys_usr_exist->rp == $request->input('password')) {
             if (DB::table('user')->select('account')->where('account', $admin_auto_sys_usr_exist->staff_cd)->count() == 0) {
                 $data = ['account' => $admin_auto_sys_usr_exist->staff_cd, 'password' => 'AdminAutomaticSystemLogin', 'type' => 'ecard', 'status' => 'available', 'role' => 'user', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
                 $query = DB::table('user');
                 $user_id = $query->insertGetId($data);
                 $data = [];
                 $data = ['user_id' => $user_id, 'name' => $request->input('name'), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
                 // 建立個人資料
                 Person::create($data);
             }
             $admin_auto_sys_usr_exist = DB::table('user')->select('id')->whereAccount($admin_auto_sys_usr_exist->staff_cd)->first();
             Auth::loginUsingId($admin_auto_sys_usr_exist->id);
             $result['status'] = 1;
         } else {
             $result['status'] = 0;
         }
     }
     return $result;
 }
Exemple #2
0
 public static function create(Request $request)
 {
     $validator = Validator::make($request->all(), self::$rule);
     $result = [];
     if ($validator->fails()) {
         $result['status'] = 0;
         $result['reason'] = $validator->errors();
     } else {
         $data = ['account' => $request->input('account'), 'password' => bcrypt($request->input('password')), 'type' => 'ecard', 'status' => 'available', 'role' => 'user', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
         $query = DB::table('user');
         $user_id = $query->insertGetId($data);
         $data = [];
         $data = ['user_id' => $user_id, 'name' => $request->input('name'), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
         // 建立個人資料
         Person::create($data);
         $result['status'] = 1;
     }
     return $result;
 }
 public function contact()
 {
     $result = Person::getContact();
     return $result;
 }