コード例 #1
0
ファイル: HomeController.php プロジェクト: CoffeeOwl17/HEXA
 private function getUserInfo()
 {
     FacebookSession::setDefaultApplication(Config::get('facebook.appid'), Config::get('facebook.secret'));
     $helper = new FacebookRedirectLoginHelper('http://localhost:8000/home');
     $userID = "";
     $userEmail = "";
     $userName = "";
     $userPicUrl = "";
     try {
         $session = $helper->getSessionFromRedirect();
     } catch (FacebookRequestException $ex) {
         // When Facebook returns an error
     } catch (\Exception $ex) {
         // When validation fails or other local issues
     }
     if (isset($_SESSION['token'])) {
         // We have a token, is it valid?
         $session = new FacebookSession($_SESSION['token']);
         try {
             $session->Validate(Config::get('facebook.appid'), Config::get('facebook.secret'));
         } catch (FacebookAuthorizationException $ex) {
             // Session is not valid any more, get a new one.
             $session = '';
         }
     }
     if (isset($session)) {
         $_SESSION['token'] = $session->getToken();
         $request = new FacebookRequest($session, 'GET', '/me?fields=id,name,email,picture');
         $response = $request->execute();
         $graphObject = $response->getGraphObject();
         $userID = $graphObject->getProperty('id');
         $userName = $graphObject->getProperty('name');
         $userEmail = $graphObject->getProperty('email');
         $userPicObj = $graphObject->getProperty('picture')->asArray();
         $userPicUrl = $userPicObj['url'];
         $_SESSION['usrID'] = $userID;
         $_SESSION['usrName'] = $userName;
         $_SESSION['usrEmail'] = $userEmail;
         $_SESSION['usrPicUrl'] = $userPicUrl;
         $user_model = App\user::where('user_id', $userID)->first();
         if (is_null($user_model)) {
             $user_model = new App\user();
             $user_model->user_id = $userID;
             $user_model->user_name = $userName;
             $user_model->user_email = $userEmail;
             $user_model->user_profilePic = $userPicUrl;
             $user_model->save();
         } else {
             $user_model->user_name = $userName;
             $user_model->user_email = $userEmail;
             $user_model->user_profilePic = $userPicUrl;
             $user_model->save();
         }
     }
     $data = array("user_id" => $userID, "user_name" => $userName, "user_email" => $userEmail, "user_profilePic" => $userPicUrl);
     $data = array("user_id" => $userID, "user_name" => $userName, "user_email" => $userEmail, "user_profilePic" => $userPicUrl);
     return $data;
 }
コード例 #2
0
 public function index()
 {
     $oauth = $_POST['inputOAuth'];
     $login = $_POST['inputLogin'];
     $name = $_POST['inputName'];
     $gender = $_POST['optGender'];
     $address = $_POST['inputAddress'];
     $email = $_POST['inputEmail'];
     $user = new App\user();
     $user->name = $name;
     $user->gender = $gender;
     $user->address = $address;
     $user->email = $email;
     $user->oauthID = $oauth;
     $user->loginType = $login;
     $saved = $user->save();
     if ($saved) {
         return view('Registration.registration_done');
     } else {
         // return redirect('/');
         return 'fail';
     }
 }
コード例 #3
0
 public function addPatient(AddPatientByStaffRequest $request)
 {
     $user = new user($request->all());
     $user->userType = 'patient';
     $user->save();
     patient::createNewPatient($user->userId, $request->all());
     return redirect('/');
 }
コード例 #4
0
ファイル: test.php プロジェクト: friendkvvk/Gags-By-Mail
 function registerdb(Request $request)
 {
     $user = new user();
     if ($user->where('email', $request['mail'])->count()) {
         return view('register', ['error' => 1]);
     } else {
         $user->name = $request['name'];
         $user->email = $request['mail'];
         $user->password = md5($request['password']);
         $user->save();
         Session::put('loginfo', 0);
         Session::put('uid', user::where('email', $request['mail'])->first()->id);
         return redirect('/');
     }
 }
コード例 #5
0
 /**
  *
  * Take the response from the Google Auth and process it
  *
  **/
 public function gauth()
 {
     $user = user::where('id', Session::get('userid'))->first();
     if (!is_null($user)) {
         return Redirect::to('home');
     }
     session_start();
     if (isset($_SESSION['OAuth_email'])) {
         /**
          *
          * Checking for the sessions variables that is proceced in the FB and Google authentication php
          * files
          *
          **/
         $userEmail = $_SESSION['OAuth_email'];
         $user = user::where('email', $userEmail)->first();
         if (is_null($user)) {
             $newUser = new user();
             $newUser->email = $userEmail;
             $pass = Str::random(10);
             $newUser->password = md5($pass);
             if (isset($_SESSION['OAuth_name'])) {
                 $newUser->name = $_SESSION['OAuth_name'];
             } else {
                 $newUser->name = "User";
             }
             $newUser->level = "1";
             $newUser->active = 1;
             $newUser->verified = 0;
             if ($newUser->save()) {
                 try {
                     Mail::send('mailtemplate/sociallogin', ['name' => $newUser->name, 'pass' => $pass], function ($m) use($newUser) {
                         $m->from('*****@*****.**', 'Native Physician');
                         $m->to($newUser->email, $newUser->name)->subject('New Password!');
                     });
                 } catch (Exception $e) {
                     //echo 'Message: ' .$e->getMessage();
                 }
                 //return "Check the Email Settings or your internet connection";
             } else {
                 return "Check the Email Settings or your internet connection";
             }
             Session::put('userid', $newUser->id);
             Session::put('user', $newUser);
             return Redirect::to('profile');
         } else {
             if ($user->active == 0) {
                 Session::flush();
                 unset($_SESSION['access_token']);
                 unset($_SESSION['OAuth_email']);
                 unset($_SESSION['OAuth_name']);
                 return Redirect::to('login');
             }
             Session::put('userid', $user->id);
             Session::put('user', $user);
             if ($user->level >= 2) {
                 $doctor = Doctor::where('email', '=', $user->email)->first();
                 if (!is_null($doctor)) {
                     Session::put('doctor', $doctor);
                 }
             }
             if (is_null(Session::get('url'))) {
                 return Redirect::to('home');
             } else {
                 return Redirect::to(Session::get('url'));
             }
         }
     } else {
         Session::flush();
         unset($_SESSION['access_token']);
         unset($_SESSION['OAuth_email']);
         unset($_SESSION['OAuth_name']);
         session_regenerate_id();
         return Redirect::to('login');
     }
 }
コード例 #6
0
 /**
  * Take All JSON Post Requset and process them
  *  Tasks
  *	 1. 
  *
  * @return Response, Views
  **/
 public function inputs()
 {
     if (Request::get('task') == "checkEmail") {
         $email = Request::get('email');
         return $this->checkEmail($email);
     } elseif (Request::get('task') == "checkPhone") {
         $phone = "";
         $phone = Request::get('phone');
         return $this->checkPhone($phone);
     } elseif (Request::get('task') == "submit") {
         /**
          *
          * Handled the main Registraion form submission
          *
          */
         $phone = Request::get('txtPhone');
         $email = Request::get('txtEmail');
         $password = Request::get('txtPassword');
         $nic = Request::get('txtNIC');
         if (is_null($phone) || is_null($email) || is_null($password)) {
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic);
         }
         $phoneVerify = json_decode($this->checkPhone($phone)->getContent(), true);
         $emailVerify = json_decode($this->checkEmail($email)->getContent(), true);
         if ($phoneVerify['code'] == "error" || $emailVerify['code'] == "error") {
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic);
         }
         $inputs = Input::all();
         $rules = ['g-recaptcha-response' => 'required|captcha'];
         $messages = ['g-recaptcha-response.required' => 'You Must Fill the Captcha', 'g-recaptcha-response.captcha' => 'Captcha Error'];
         $validator = Validator::make($inputs, $rules, $messages);
         if ($validator->fails()) {
             $errors = $validator->messages();
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic)->with('captcha', 'Captcha Erro');
         }
         $newUser = new user();
         $newUser->email = $email;
         if (!is_null($nic)) {
             $newUser->nic = $nic;
         }
         $newUser->password = md5($password);
         $phone = "+94" . $phone;
         $newUser->tp = $phone;
         $newUser->level = "1";
         $newUser->active = 1;
         $newUser->verified = 0;
         $newUser->save();
         try {
             Mail::send('mailtemplate/sociallogin', ['name' => $newUser->name, 'pass' => $password], function ($m) use($newUser) {
                 $m->from('*****@*****.**', 'Native Physician');
                 $m->to($newUser->email, $newUser->name)->subject('New Password!');
             });
         } catch (Exception $e) {
             //echo 'Message: ' .$e->getMessage();
         }
         Session::put('loginMsg', 'user_created');
         return Redirect::to('login');
     }
 }