Example #1
0
 /**
  * @author: lmkhang (skype)
  * @date: 2016-01-15
  * Action: Admin login
  */
 public function login(Request $request)
 {
     //check islogged
     if ($this->isLoggedAdmin()) {
         //set Flash Message
         $this->setFlash('message', 'Logged!');
         return Redirect::intended('/adminntw')->with('message', 'Logged!');
     }
     $post = $request->all();
     $info = $this->trim_all($post['login']);
     //Setup validation
     $validator = Validator::make($info, ['account' => 'required|min:5|max:100', 'password' => 'required|min:5|max:50']);
     //Checking
     if ($validator->fails()) {
         // The given data did not pass validation
         //set Flash Message
         $this->setFlash('message', 'Errors!');
         return redirect()->back();
     }
     $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
     $pwd = $this->encryptString($info['password'], $salt);
     $admin_get = new \App\Admin();
     $admin = $admin_get->checkAccount($info['account'], $pwd);
     //set Session
     if (!$admin) {
         //set Flash Message
         $this->setFlash('message', 'This account is not available!');
         return redirect()->back()->with('message', 'This account is not available!');
     }
     //set Session
     $this->setLogSession($admin->toArray());
     //set Flash Message
     $this->setFlash('message', 'Login successfully!');
     return Redirect::intended('/adminntw')->with('message', 'Login successfully!');
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //faker
     $faker = Faker\Factory::create('ja_JP');
     //loop
     for ($i = 0; $i < 25; $i++) {
         $admin = new App\Admin();
         $admin->name = $faker->userName();
         $admin->email = $faker->unique()->email();
         $admin->password = Hash::make($admin->email);
         $admin->save();
     }
 }
Example #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //super user
     //Truncate
     App\Admin::truncate();
     //Admin
     $admin1 = new App\Admin();
     $admin1->name = "admin1";
     $admin1->email = "*****@*****.**";
     $admin1->password = Hash::make('admin1');
     $admin1->role = 2;
     //Save
     $admin1->save();
     //general user
     //Admin
     $admin2 = new App\Admin();
     $admin2->name = "admin2";
     $admin2->email = "*****@*****.**";
     $admin2->password = Hash::make('admin2');
     $admin2->role = 1;
     //Save
     $admin2->save();
 }
Example #4
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-04
  * Checking existed account
  */
 protected function checkAccount($info)
 {
     //Check isLogged
     if ($this->isLoggedAdmin()) {
         die;
     }
     //Message
     $result = null;
     //Check Username
     if (isset($info['account']) && $info['account'] && isset($info['password']) && $info['password']) {
         $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
         $password = $this->encryptString($info['password'], $salt);
         $admin = new \App\Admin();
         $result = $admin->checkAccount($info['account'], $password);
     }
     return $result;
 }
Example #5
0
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('admins')->delete();
     App\Admin::create(['username' => 'rizwan965', 'password' => Hash::make('torque@!?')]);
 }
Example #6
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-10
  * Checking admin login
  */
 public function admin_login(Request $request)
 {
     if ($this->isLoggedAdmin()) {
         die;
     }
     $message = 'This account is not available';
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $post = $request->all();
         $info = $this->trim_all($post['login']);
         $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
         $pwd = $this->encryptString($info['password'], $salt);
         $admin_get = new \App\Admin();
         $admin = $admin_get->checkAccount($info['account'], $pwd);
         //set Session
         if ($admin) {
             $message = '';
         }
         header('Content-Type: application/json');
         echo json_encode(['message' => $message]);
         exit;
     }
 }