/**
  * Find the User via their email if they exist
  * creates a new User if they don't exist.
  * @param  Socialite $socialAccount
  * @return User model
  */
 public function findByEmailOrCreate($socialAccount)
 {
     if (!User::whereEmail($socialAccount->email)->exists()) {
         return User::create(['first_name' => $socialAccount->name, 'email' => $socialAccount->email, 'confirmed' => true]);
     }
     return User::whereEmail($socialAccount->email)->first();
 }
Example #2
0
 public function login()
 {
     if (\Request::all()) {
         $validator = \Validator::make(\Request::all(), ['email' => 'required|email', 'password' => 'required']);
         if ($validator->fails()) {
             return \Redirect::to('/administrator')->withErrors($validator)->withInput();
         } else {
             $email = \Request::get('email');
             $password = \Request::get('password');
             $user = \User::whereEmail($email)->first();
             if ($user) {
                 if (\Hash::check($password, $user->password)) {
                     //Если нужна еще роль то тут добавить условие с ролью
                     if (\Auth::attempt(['email' => $email, 'password' => $password, 'role' => '1']) or \Auth::attempt(['email' => $email, 'password' => $password, 'role' => '2'])) {
                         return \Redirect::route('dashboard');
                     } else {
                         return \Redirect::route('administrator');
                     }
                 } else {
                     $errors['password'] = "******";
                     return \Redirect::route('administrator')->withInput()->withErrors($errors);
                 }
             } else {
                 $errors['email'] = "Данный адрес не зарегестрирован";
                 return \Redirect::route('administrator')->withInput()->withErrors($errors);
             }
             return view('abadmin::login');
         }
     }
     return view('abadmin::login');
 }
 public function doMeta()
 {
     $error = false;
     //  Set our metadata
     Metadata::set(Input::except(['user', 'pass', '_token']));
     Metadata::set('theme', 'default');
     //  Check the Stripe API key is valid
     try {
         Stripe::setApiKey(Metadata::item('stripe_key'));
         Stripe\Balance::retrieve();
     } catch (Exception $e) {
         $error = 'That Stripe key doesn’t look valid!';
     }
     //  Create the user
     if (User::whereEmail(Input::get('user'))->exists()) {
         //  We're installing, can't have users already (I think)
         // $error = 'Somebody’s already signed up with that email address!';
     } else {
         User::create(['username' => 'admin', 'name' => 'Administrator', 'level' => User::level('admin'), 'email' => Input::get('user'), 'password' => Input::get('pass')]);
     }
     if ($error === false) {
         return Redirect::to('install/done');
     }
     View::share('error', $error);
     return self::showMeta();
 }
 public function postForgetPassword()
 {
     $validator = Validator::make(Input::all(), array('email' => 'required|email'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $email = Input::get('email');
         $check = User::whereEmail($email)->first();
         if ($check) {
             $username = $check->username;
             $name = $check->displayname;
             $password = str_random(10);
             $check->resetcode = str_random(60);
             $check->tmp_password = Hash::make($password);
             $code = $check->resetcode . $password;
             if ($check->save()) {
                 Mail::send('emails.auth.forget_password', array('link' => URL::to('account/recover', $code), 'name' => $name, 'username' => $username, 'password' => $password), function ($message) use($email, $name) {
                     $message->to($email, $name)->subject('Reset Password');
                 });
                 return Redirect::to('account/login')->with('success', 'Password reset link send to your mail');
             }
         } else {
             return Redirect::back()->withErrors(array('error' => 'Please enter registered email'))->withInput();
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $remember = Input::has('remember') ? true : false;
     $user = User::whereEmail(Input::get('email'))->first();
     //if the user is not locked count number of attempts
     if ($user->locked == 0) {
         if (Session::has('loginAttempts')) {
             $loginAttempts = Session::get('loginAttempts');
             if ($loginAttempts > 2) {
                 if (Session::has('passwordResetSent')) {
                     Session::set('passwordResetSent', 1);
                 } else {
                     Session::put('passwordResetSent', 1);
                 }
                 $user->locked = 1;
                 $user->save();
             }
         } else {
             Session::put('loginAttempts', 0);
         }
     }
     $rules = ['email' => 'required|exists:users', 'password' => 'required'];
     $input = Input::only('email', 'password');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $auth = Auth::attempt(['email' => Input::get('email'), 'password' => Input::get('password'), 'confirmed' => 1, 'locked' => 0], $remember);
     if ($auth) {
         if (Session::has('loginAttempts')) {
             Session::set('loginAttempts', 0);
         }
         Flash::message('Welcome back!');
         return Redirect::action('HomeController@index');
     } else {
         //			call function increase login attempts for this email then send email
         if (Session::get('passwordResetSent') == 1) {
             Session::set('passwordResetSent', 0);
             $new_pass = str_random(4);
             $user_email = Input::get('email');
             $user->password = Hash::make($new_pass);
             $user->save();
             Mail::send('emails.new_pass_account_locked', compact('new_pass', 'user_email'), function ($message) {
                 $message->to(Input::get('email'), Input::get('email'))->subject('Account Locked, New Password');
             });
         } else {
             if (Session::has('loginAttempts')) {
                 $loginAttempts = Session::get('loginAttempts');
                 Session::set('loginAttempts', $loginAttempts + 1);
             }
         }
         if ($user->locked == 1) {
             Flash::message('Account needs to be confirmed! Please check email');
         }
         return Redirect::back()->withInput()->withErrors(['credentials' => 'Your username/password combination was incorrect.']);
     }
 }
 public function loginUser()
 {
     $data = Input::all();
     if (Auth::attempt(array('email' => $data['email'], 'password' => $data['password'], 'is_confirmed' => 1), true)) {
         $user = User::whereEmail($data['email'])->first();
         return Response::json(array('success' => true, 'user' => $user));
     }
     return Response::json(array('success' => false, 'error' => 'OOPS... looks like some of the details are wrong. Please try again'));
 }
    public function run()
    {
        DB::table('posts')->delete();
        $camoiloc = User::whereEmail('*****@*****.**')->first()->id;
        $darjaalymova = User::whereEmail('*****@*****.**')->first()->id;
        Post::create(array('user_id' => $camoiloc, 'title' => 'Blog Post Title 1', 'content' => 'Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. 
Boudin aliqua adipisicing rump corned beef. Nulla corned beef sunt ball tip, qui bresaola enim jowl. Capicola short ribs minim salami nulla nostrud pastrami.'));
        Post::create(array('user_id' => $darjaalymova, 'title' => 'Blog Post Title 2', 'content' => 'Pork drumstick turkey fugiat. Tri-tip elit turducken pork chop in. Swine short ribs meatball irure bacon nulla pork belly cupidatat meatloaf cow. Nulla corned beef sunt ball tip, qui bresaola enim jowl. Capicola short ribs minim salami nulla nostrud pastrami. Nulla corned beef sunt ball tip, qui bresaola enim jowl. Capicola short ribs minim salami nulla nostrud pastrami.'));
        Post::create(array('user_id' => $camoiloc, 'title' => 'Blog Post Title 3', 'content' => 'Pork drumstick turkey fugiat. Tri-tip elit turducken pork chop in. Swine short ribs meatball irure bacon nulla pork belly cupidatat meatloaf cow. Nulla corned beef sunt ball tip, qui bresaola enim jowl. Capicola short ribs minim salami nulla nostrud pastrami. Nulla corned beef sunt ball tip, qui bresaola enim jowl. Capicola short ribs minim salami nulla nostrud pastrami.'));
    }
 public function validate()
 {
     $rules = array('email' => 'required|email|exists:users,email');
     $validator = \Validator::make($this->input(), $rules);
     if ($validator->passes()) {
         $user = \User::whereEmail($this->input('email'))->first();
         if ($user->having('activation', 'exists', true)->get(['_id'])->isEmpty()) {
             $this->error(['global' => 'This account has already been activated.']);
         }
     } else {
         $this->error($validator);
     }
 }
 public function profile_update(ProfileRequest $request)
 {
     // Comprobar si el email existe solo si se ha cambiado el email
     if ($request->email != auth()->user()->email) {
         $user = User::whereEmail($request->email)->get();
         if (!empty($user)) {
             alert('El email ingresado ya existe', 'danger');
             return redirect()->back();
         }
     }
     $state = State::findOrFail($request->state);
     $user = auth()->user();
     $user->state()->associate($state);
     $user->update($request->all());
     alert('Se modificaron los datos con éxito');
     return redirect()->back();
 }
 public function send_new_pass()
 {
     try {
         $email = Input::get('request_pass_email');
         $user = User::whereEmail($email)->first();
         $link = URL::to('dashboard/' . $this->hashids->encrypt($user->id) . '/reset-pass-from-email');
         $name = $user->first_name . ' ' . $user->last_name;
         $data = ['user' => $user, 'link' => $link];
         $result = Mailgun::send('backend.emails.auth.click-to-reset-pass', $data, function ($message) use($user, $name) {
             $message->from($this->admin->email, $this->admin->first_name)->subject($this->setting->sitename . ' Admin Password Reset')->to($user->email, $name)->tag('Password Recovery');
         });
         if (is_object($result)) {
             return Response::json(['success' => 'An email has been sent to you with instructions on how to reset your password.']);
         } else {
             return Response::json(['error' => 'An error was encountered sending the email. Please try again or contact server admin.']);
         }
     } catch (Exception $e) {
         return Response::json(array('error' => 'An error occurred. Kindly try again or contact admin.'));
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!file_exists($filename) || !is_file($filename)) {
         $this->error(sprintf('Fichier inconnu: %s', $filename));
         return false;
     }
     $emailAlias = array('*****@*****.**' => '*****@*****.**', '*****@*****.**' => '*****@*****.**');
     $skip = array('*****@*****.**');
     $reader = Reader::createFromPath($filename);
     $reader->setDelimiter(';');
     $reader->each(function ($row, $index, $iterator) use($reader, $skip, $emailAlias) {
         if ($index > 0) {
             // skip header
             if (count($row) == 7) {
                 $email = $row[3];
                 if (isset($emailAlias[$email])) {
                     $email = $emailAlias[$email];
                 }
                 if (!in_array($email, $skip)) {
                     $user = User::whereEmail($email)->first();
                     if (!is_object($user)) {
                         $user = new User();
                         $user->firstname = $row[1];
                         $user->lastname = $row[0];
                         $user->email = $email;
                         $user->phone = str_replace('Ph. ', '', $row[4]);
                         $user->role = 'member';
                         $user->password = Hash::make('etincelle');
                         $user->save();
                         Mail::send('emails.skedda-migration', array('user' => $user), function ($m) use($user) {
                             $m->from('*****@*****.**', 'Sébastien Hordeaux')->bcc('*****@*****.**', 'Sébastien Hordeaux')->to($user->email, $user->fullname)->subject('Etincelle Coworking - Outil de réservation de salles');
                         });
                         $this->info(sprintf('%s: OK', $user->fullname));
                     }
                 }
             }
         }
         return true;
     });
 }
 /**
  * Update the specified resource in storage.
  * POST /updateuser
  *
  * @return Response
  */
 public function updateUser()
 {
     $arr = array();
     $missingParam = '';
     if (Input::get('first_name') == '') {
         $missingParam .= 'first_name,';
     }
     //if(Input::get('last_name') == '')$missingParam .= 'last_name,';
     if (Input::get('email') == '') {
         $missingParam .= 'email,';
     }
     if (Input::get('language') == '') {
         $missingParam .= 'language,';
     }
     if (Input::get('provider') == '') {
         $missingParam .= 'provider,';
     }
     if (Input::get('provider_info') == '') {
         $missingParam .= 'provider_info,';
     }
     if ($missingParam != '') {
         $arr['Success'] = false;
         $arr['Status'] = 'Parameter missing: ' . rtrim($missingParam, ',');
         $arr['StatusCode'] = 400;
     } else {
         $user = User::whereEmail(Input::get('email'))->first();
         if ($user) {
             $user->language = Input::get('language');
             $user->first_name = Input::get('first_name');
             $user->last_name = Input::get('last_name');
             $user->gender = Input::get('gender') != '' && Input::get('gender') != 'null' ? Input::get('gender') : '';
             $user->address = Input::get('address') != '' && Input::get('address') != 'null' ? Input::get('address') : '';
             $user->city = Input::get('city') != '' && Input::get('city') != 'null' ? Input::get('city') : '';
             $user->state = Input::get('state') != '' && Input::get('state') != 'null' ? Input::get('state') : '';
             $user->country = Input::get('country') != '' && Input::get('country') != 'null' ? Input::get('country') : '';
             $user->zipcode = Input::get('zipcode') != '' && Input::get('zipcode') != 'null' ? Input::get('zipcode') : '';
             $user->phone = Input::get('phone') != '' && Input::get('phone') != 'null' ? Input::get('phone') : '';
             $user->dob = Input::get('dob') != '' && Input::get('dob') != 'null' ? Input::get('dob') : '';
             $user->provider = Input::get('provider') != '' && Input::get('provider') != 'null' ? Input::get('provider') : '';
             $user->provider_info = Input::get('provider_info') != '' && Input::get('provider_info') != 'null' ? Input::get('provider_info') : '';
             $photoName = '';
             if (Input::get('photo')) {
                 $photoString = Input::get('photo');
                 $photoDecode = base64_decode($photoString);
                 // decode image
                 try {
                     $im = imagecreatefromstring($photoDecode);
                 } catch (Exception $e) {
                     $arr['Success'] = false;
                     $arr['Status'] = ' Empty string or invalid image';
                     $arr['StatusCode'] = 400;
                     return Response::json($arr);
                 }
                 if ($im !== false) {
                     // saves an image to specific location
                     $photoName = time() . '.png';
                     $resp = imagepng($im, Config::get('app.upload_folder') . '/' . $photoName);
                     // frees image from memory
                     imagedestroy($im);
                 } else {
                     $arr['Success'] = false;
                     $arr['Status'] = 'Failed to upload image';
                     $arr['StatusCode'] = 400;
                 }
                 $user->photo = $photoName;
             }
             $user->save();
             $userData = User::whereEmail(Input::get('email'))->first();
             $arr['Success'] = true;
             $arr['Status'] = 'OK';
             $arr['StatusCode'] = 200;
             $arr['language'] = Input::get('language');
             $arr['Result']['firstName'] = $userData->first_name;
             $arr['Result']['lastName'] = $userData->last_name;
             $arr['Result']['gender'] = $userData->gender;
             $arr['Result']['address'] = $userData->address;
             $arr['Result']['city'] = $userData->city;
             $arr['Result']['state'] = $userData->state;
             $arr['Result']['country'] = $userData->country;
             $arr['Result']['zipcode'] = $userData->zipcode;
             $arr['Result']['phone'] = $userData->phone;
             $arr['Result']['email'] = $userData->email;
             $arr['Result']['dob'] = $userData->dob;
             $arr['Result']['provider'] = $userData->provider;
             $arr['Result']['provider_info'] = $userData->provider_info;
             if ($photoName != '') {
                 $arr['Result']['photo'] = Config::get('app.photo_url') . '/' . $photoName;
             }
             $arr['Result']['authToken'] = Config::get('app.persistent-api-key');
             $arr['Result']['isactive'] = $userData->status;
         } else {
             $arr['Success'] = false;
             $arr['Status'] = 'User not found';
             $arr['StatusCode'] = 404;
         }
     }
     return Response::json($arr);
 }
 public function postForgotPassword()
 {
     $input = Input::all();
     $validator = User::validate_reset($input);
     if ($validator->passes()) {
         $user = User::whereEmail($input['email'])->first();
         if ($user) {
             $user = Sentry::findUserByLogin($user->username);
             $resetCode = $user->getResetPasswordCode();
             $data = array('user_id' => $user->id, 'resetCode' => $resetCode);
             Mail::queue('backend.' . $this->current_theme . '.reset_password_email', $data, function ($message) use($input, $user) {
                 $message->from(get_setting('email_username'), Setting::value('website_name'))->to($input['email'], "{$user->first_name} {$user->last_name}")->subject('Password reset ');
             });
             return Redirect::back()->with('success_message', 'Password reset code has been sent to the email address. Follow the instructions in the email to reset your password.');
         } else {
             return Redirect::back()->with('error_message', 'No user exists with the specified email address');
         }
     } else {
         return Redirect::back()->withInput()->with('error_message', implode('<br>', $validator->messages()->get('email')));
     }
 }
 /**
  * Update selfie video
  * POST /updateselfievideo
  *
  * @return Response
  */
 public function updateSelfieVideo()
 {
     $arr = array();
     $missingParam = '';
     if (Input::get('title') == '') {
         $missingParam .= 'title,';
     }
     if (Input::get('youtube_id') == '') {
         $missingParam .= 'youtube_id,';
     }
     if (Input::get('youtube_url') == '') {
         $missingParam .= 'youtube_url,';
     }
     if (Input::get('language') == '') {
         $missingParam .= 'language,';
     }
     if (Input::get('email') == '') {
         $missingParam .= 'email,';
     }
     if (Input::get('video_id') == '') {
         $missingParam .= 'video_id,';
     }
     if (Input::get('scripture_text') == '') {
         $missingParam .= 'scripture_text,';
     }
     if (Input::get('country') == '') {
         $missingParam .= 'country,';
     }
     if (Input::get('topics') == '') {
         $missingParam .= 'topics,';
     }
     if ($missingParam != '') {
         $arr['Success'] = false;
         $arr['Status'] = 'Parameter missing: ' . rtrim($missingParam, ',');
         $arr['StatusCode'] = 400;
     } else {
         $user = User::whereEmail(Input::get('email'))->first();
         if ($user) {
             $video = Video::whereVideoId(Input::get('video_id'))->first();
             if ($video) {
                 //save video
                 $userId = $user->id;
                 $video->video_title = Input::get('title');
                 $video->video_desc = Input::get('description');
                 $video->video_short_desc = Input::get('description');
                 $video->video_youtube_id = Input::get('youtube_id');
                 $embedCode = "<iframe type='text/html' src='http://www.youtube.com/embed/" . Input::get('youtube_id') . "' width='640' height='360' frameborder='0' allowfullscreen='true'/></iframe>";
                 $video->video_embed = $embedCode;
                 $video->video_url = Input::get('youtube_url');
                 $video->video_thumbnail_url = Input::get('youtube_thumbnail_url');
                 $video->scripture_text = Input::get('scripture_text');
                 $video->video_language = Input::get('language');
                 $video->video_country = Input::get('country');
                 $video->user_id = $userId;
                 $video->save();
                 //Video Tags
                 if (Input::get('tags') != '') {
                     $tags = Input::get('tags');
                     if (strpos($tags, ',') !== FALSE) {
                         //Split by comma
                         $tagList = explode(',', $tags);
                         if (count($tagList) > 0) {
                             foreach ($tagList as $tagName) {
                                 $tagDetails = Tag::wherehashName($tagName)->first();
                                 //Tag exists, then save it
                                 if ($tagDetails) {
                                     $tagId = $tagDetails->hash_id;
                                 } else {
                                     //Tag not exists, then add it and return id
                                     $tg = new Tag();
                                     $tg->hash_name = $tagName;
                                     $tg->hash_language = Input::get('language');
                                     $tg->save();
                                     $tagId = $tg->id;
                                 }
                                 if ($tagId > 0) {
                                     //Check if the relation already exists,if not add
                                     $count = VideoHash::where('video_id', '=', Input::get('video_id'))->where('hash_id', '=', $tagId)->count();
                                     if ($count == 0) {
                                         $videoh = new VideoHash();
                                         $videoh->video_id = Input::get('video_id');
                                         $videoh->hash_id = $tagId;
                                         $videoh->push();
                                     }
                                 }
                             }
                         }
                     } else {
                         //Tag doesn't contain comma
                         $tagDetails = Tag::wherehashName($tags)->first();
                         //Tag exists, then save it
                         if ($tagDetails) {
                             $tagId = $tagDetails->hash_id;
                         } else {
                             //Tag not exists, then add it and return id
                             $tg = new Tag();
                             $tg->hash_name = $tags;
                             $tg->hash_language = Input::get('language');
                             $tg->save();
                             $tagId = $tg->id;
                         }
                         if ($tagId > 0) {
                             //Check if the relation already exists,if not add
                             $count = VideoHash::where('video_id', '=', Input::get('video_id'))->where('hash_id', '=', $tagId)->count();
                             if ($count == 0) {
                                 $videoh = new VideoHash();
                                 $videoh->video_id = Input::get('video_id');
                                 $videoh->hash_id = $tagId;
                                 $videoh->push();
                             }
                         }
                     }
                 }
                 //Topics
                 if (Input::get('topics') != '') {
                     $topics = Input::get('topics');
                     if (strpos($topics, ',') !== FALSE) {
                         //Split by comma
                         $topicList = explode(',', $topics);
                         if (count($topicList) > 0) {
                             foreach ($topicList as $topicId) {
                                 //Check if the relation already exists,if not add
                                 $countTopic = VideoTopic::where('video_id', '=', Input::get('video_id'))->where('topic_id', '=', $topicId)->count();
                                 if ($countTopic == 0) {
                                     $videotopic = new VideoTopic();
                                     $videotopic->video_id = $videoId;
                                     $videotopic->topic_id = $topicId;
                                     $videotopic->push();
                                 }
                             }
                         }
                     }
                 } else {
                     $countTopic = VideoTopic::where('video_id', '=', Input::get('video_id'))->where('topic_id', '=', Input::get('topics'))->count();
                     if ($countTopic == 0) {
                         $videotopic = new VideoTopic();
                         $videotopic->video_id = $videoId;
                         $videotopic->topic_id = $Input::get('topics');
                         $videotopic->push();
                     }
                 }
                 //Get saved video details
                 $updatedSelfie = Video::wherevideoId(Input::get('video_id'))->first();
                 $arr['Success'] = true;
                 $arr['Status'] = 'OK';
                 $arr['StatusCode'] = 200;
                 $arr['language'] = Input::get('language');
                 $arr['Result']['email'] = Input::get('email');
                 $arr['Result']['video_id'] = Input::get('video_id');
                 $arr['Result']['title'] = $updatedSelfie->video_title;
                 $arr['Result']['description'] = $updatedSelfie->video_desc;
                 $arr['Result']['video_short_desc'] = $updatedSelfie->video_desc;
                 $arr['Result']['youtube_id'] = $updatedSelfie->video_youtube_id;
                 $arr['Result']['embedcode'] = $updatedSelfie->video_embed;
                 $arr['Result']['youtube_url'] = $updatedSelfie->video_url;
                 $arr['Result']['youtube_thumbnail_url'] = $updatedSelfie->video_thumbnail_url;
                 $arr['Result']['scripture_text'] = $updatedSelfie->scripture_text;
                 $arr['Result']['country'] = $updatedSelfie->video_country;
             } else {
                 $arr['Success'] = false;
                 $arr['Status'] = 'Video not found';
                 $arr['StatusCode'] = 404;
             }
         } else {
             $arr['Success'] = false;
             $arr['Status'] = 'User with this email does not exist';
             $arr['StatusCode'] = 404;
         }
     }
     return Response::json($arr);
 }
 public function account_locked_confirm($user_email)
 {
     if (Session::has('loginAttempts')) {
         Session::set('loginAttempts', 0);
     }
     $user = User::whereEmail($user_email)->first();
     Flash::message('A break-in attempt was detected on your account. Account confirmed! Please log back in with new password!');
     $user->locked = 0;
     $user->save();
     return Redirect::route('sessions.create');
 }
 /**
  * Assign a token to reset the password of the user with the given email.
  *
  * @author	Andrea Marco Sartori
  * @param	string	$token
  * @param	string	$email
  * @return	void
  */
 public function assignResetToken($token, $email)
 {
     $user = $this->user->whereEmail($email)->first();
     $user->reset_token = $token;
     $user->save();
 }
 public function postResendConfirmationEmail()
 {
     $email = Input::get('email');
     $user = User::whereEmail($email)->first();
     if (!$user) {
         return Redirect::action('UserController@getResendConfirmationEmail')->with(['error' => __('userNotFound')]);
     }
     if (empty($user->confirmation_code)) {
         $confirmationCode = str_random(30);
         $user->confirmation_code = $confirmationCode;
         $user->save();
     }
     //Send confirmation email
     $confirmEmailNotification = new Notifications\ConfirmEmail($user, $user->confirmation_code);
     $confirmEmailNotification->send();
     return Redirect::action('UserController@getResendConfirmationEmail')->with(['status' => __('confirmationEmailSent')]);
 }
Example #18
0
 public function notAjaxLogin()
 {
     $user = User::whereEmail(Input::get('email'))->first();
     //Ищется пользователь с таким именем
     if (!isset($user->email)) {
         //проверяется его существование, если такого имени нет, то в топку
         return Redirect::back()->withInput()->withErrors(['msg' => ['Неверно указан email или пароль']]);
     }
     $role = $user->roles->first();
     if ($role->name == 'member') {
         if (Auth::attempt(Input::only('email', 'password'))) {
             Session::put('role', 'member');
             Session::put('email', $user->email);
             Session::put('id', $user->id);
             Session::put('confirmed', $user->confirmed);
         } else {
             return Redirect::back()->withInput()->withErrors(['msg' => ['Неверно указан email или пароль']]);
         }
         $lang = $user->language;
         Session::put('lang', $lang);
         return Redirect::to('/profile');
     } elseif ($role->name == 'miniadmin') {
         if (Auth::attempt(Input::only('email', 'password'))) {
             Session::put('role', 'miniadmin');
             Session::put('email', $user->email);
             Session::put('id', $user->id);
             return Redirect::to('/admin');
         }
     }
 }
Example #19
0
});
Route::get('login/fb/callback', function () {
    $code = Input::get('code');
    if (strlen($code) == 0) {
        return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
    }
    $facebook = new Facebook(Config::get('facebook'));
    $uid = $facebook->getUser();
    if ($uid == 0) {
        return Redirect::to('/')->with('message', 'There was an error');
    }
    $me = $facebook->api('/me');
    $profile = Profile::whereUid($uid)->first();
    if (empty($profile)) {
        //check if there is a user registered on clasic way
        $user = User::whereEmail($me['email'])->first();
        if ($user) {
            $profile = new Profile();
            $profile->uid = $uid;
            $profile->username = $me['username'];
            $profile = $user->profiles()->save($profile);
        } else {
            $user = new User();
            // $user->name = $me['first_name'] . ' ' . $me['last_name'];
            $user->email = $me['email'];
            // $user->photo = 'https://graph.facebook.com/' . $me['username'] . '/picture?type=large';
            $user->save();
            $profile = new Profile();
            $profile->uid = $uid;
            $profile->username = $me['username'];
            $profile = $user->profiles()->save($profile);