/**
  * postSignin
  * --------------------------------------------------
  * @return Processes the signin request, signs in the user
  * --------------------------------------------------
  */
 public function postSignin()
 {
     /* Validation */
     $rules = array('email' => 'required|email', 'password' => 'required');
     /* run the validation rules on the inputs */
     $validator = Validator::make(Input::all(), $rules);
     /* Everything is OK */
     if (!$validator->fails() and Auth::attempt(Input::only('email', 'password'))) {
         /* Track event | SIGN IN */
         $tracker = new GlobalTracker();
         $tracker->trackAll('lazy', array('en' => 'Sign in', 'el' => Auth::user()->email));
         /* Make welcome message */
         if (Auth::user()->name) {
             $message = 'Welcome back, ' . Auth::user()->name . '!';
         } else {
             $message = 'Welcome back.';
         }
         /* Redirect to dashboard */
         return Redirect::route('dashboard.dashboard')->with('success', $message);
         /* Something is not OK (bad credentials) */
     } else {
         /* Redirect to signin with error message */
         return Redirect::route('auth.signin')->with('error', 'The provided email address or password is incorrect.')->withInput(Input::except('password'));
     }
 }
 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Creator - ' . $this->site_name;
     $creator = Creator::find($id);
     $input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug');
     $messages = ['unique' => 'The modpack creator already exists in the database.', 'url' => 'The :attribute field is not a valid URL.'];
     $validator = Validator::make($input, ['name' => 'required|unique:creators,name,' . $creator->id, 'website' => 'url', 'donate_link' => 'url'], $messages);
     if ($validator->fails()) {
         return Redirect::action('CreatorController@getAdd')->withErrors($validator)->withInput();
     }
     $creator->name = $input['name'];
     $creator->deck = $input['deck'];
     $creator->website = $input['website'];
     $creator->donate_link = $input['donate_link'];
     $creator->bio = $input['bio'];
     if ($input['slug'] == '' || $input['slug'] == $creator->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $creator->slug = $slug;
     $creator->last_ip = Request::getClientIp();
     $success = $creator->save();
     if ($success) {
         return View::make('creators.edit', ['title' => $title, 'creator' => $creator, 'success' => true]);
     }
     return Redirect::action('CreatorController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack creator.'])->withInput();
 }
Example #3
0
 public function join()
 {
     $data = Input::only(['name', 'room_id']);
     print_r($data);
     $room = Room::find($data['room_id']);
     if (!$room) {
         return Redirect::action('PrepareController@room');
     }
     if ($room->state !== 'open') {
         throw new BadRequestHttpException('既にゲームは開始しています。');
     }
     if ($room->mates->count() >= $room->member_number) {
         throw new BadRequestHttpException('全ユーザーが揃っています');
     }
     if (!isset($data['name']) || $data['name'] == '') {
         //名前指定していない場合
         return Redirect::action('PrepareController@rooms');
     }
     $i = 0;
     do {
         $hash = sha1(date("Y/m/d H:i:s.u") . 'zCeZu12X' . $data['name'] . $data['room_id']);
         $hashed_mate = Mate::where('hash', $hash)->select('hash')->first();
         $i++;
         if ($i > 50) {
             throw new InternalErrorException('ユーザー作成に失敗しました hash衝突しまくり');
         }
     } while ($hashed_mate && $i < 100);
     $mate = Mate::create(['name' => $data['name'], 'last_state' => 'open', 'hash' => $hash, 'cast_id' => 0, 'room_id' => $data['room_id'], 'select_user_id' => '', 'is_alive' => 1]);
     if (!$mate) {
         throw new InternalErrorException('ユーザー作成に失敗しました');
     }
     $room->touch();
     return Redirect::action('PlayController@index', ['hash' => $hash]);
 }
 /**
  * Store a newly created resource in storage.
  * POST /sessions
  *
  * @return Response
  */
 public function store()
 {
     if (Auth::attempt(Input::only('email', 'password'))) {
         return Redirect::to('/reservation');
     }
     return Redirect::back();
 }
Example #5
0
 public function getAvailableSchoolsAttribute()
 {
     $filters = array_filter(Input::only('specialty', 'district', 'municipality', 'city', 'type', 'search'));
     $filters['financing'][] = $this->id;
     $schools_data = new School();
     return $schools_data->filterSchools($filters)->get()->count();
 }
 /**
  * Update the specified karyawan in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $rules = array('first_name' => 'required', 'unit_kerja' => 'required|exists:unitkerjas,id', 'unit' => 'required|exists:units,id', 'jabatan' => 'required|exists:jabatans,id');
     $karyawan = User::findOrFail($id);
     $validator = Validator::make($data = Input::only('first_name', 'last_name', 'nip', 'unit_kerja', 'unit', 'jabatan'), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         //code
         DB::table('users')->where('id', $id)->update(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'nip' => Input::get('nip'), 'unit_kerja' => Input::get('unit_kerja'), 'unit' => Input::get('unit'), 'jabatan' => Input::get('jabatan')));
         // Find the user using the user id
         //$usergroupremove = Sentry::getUserProvider()->findById($id);
         // Find the group using the group id
         //$groupremove = Sentry::findGroupById($usergroupremove->getGroups());
         // Assign the group to the user
         //$usergroupremove->removeGroup($groupsremove);
         // Find the user using the user id
         //$user = Sentry::findUserById($id);
         // Find the group using the group id
         //$adminGroup = Sentry::findGroupById(Input::get('group'));
         // Assign the group to the user
         //$user->addGroup($adminGroup);
         //$user->save();
     }
     $karyawan->update($data);
     return Redirect::route('admin.karyawan.index')->with("successMessage", "Berhasil menyimpan {$karyawan->first_name}. ");
 }
Example #7
0
 public function postNewUser()
 {
     // Grab the inputs and validate them
     $new_user = Input::only('email', 'username', 'password', 'first_name', 'last_name', 'is_admin');
     $validation = new Validators\SeatUserRegisterValidator();
     // Should the form validation pass, continue to attempt to add this user
     if ($validation->passes()) {
         // Because users are soft deleted, we need to check if if
         // it doesnt actually exist first.
         $user = \User::withTrashed()->where('email', Input::get('email'))->orWhere('username', Input::get('username'))->first();
         // If we found the user, restore it and set the
         // new values found in the post
         if ($user) {
             $user->restore();
         } else {
             $user = new \User();
         }
         // With the user object ready, work the update
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->activated = 1;
         $user->save();
         // After user is saved and has a user_id
         // we can add it to the admin group if necessary
         if (Input::get('is_admin') == 'yes') {
             $adminGroup = \Auth::findGroupByName('Administrators');
             Auth::addUserToGroup($user, $adminGroup);
         }
         return Redirect::action('UserController@getAll')->with('success', 'User ' . Input::get('email') . ' has been added');
     } else {
         return Redirect::back()->withInput()->withErrors($validation->errors);
     }
 }
 /**
  * Creates a new user
  *
  * @return String
  */
 public function store()
 {
     $this->RegistrationForm->validate(Input::all());
     $user = User::create(Input::only('email', 'password'));
     Auth::login($user);
     return Redirect::home();
 }
 /**
  * Authenticate the user
  * @return [type] [description]
  */
 public function store()
 {
     if (Auth::attempt(Input::only('email', 'password'), true)) {
         return Redirect::intended('/');
     }
     return Redirect::back()->withInput()->withErrors(['Invalid Email or Password']);
 }
Example #10
0
 public function login()
 {
     $data = Input::only('email', 'password', 'remember');
     $credeciales = ['email' => $data['email'], 'password' => $data['password']];
     if (Auth::attempt($credeciales, $data['remember'])) {
         $data = [Auth::user()->full_name, Auth::user()->email, Auth::user()->tipo];
         if (Auth::user()->tipo == 'asistente') {
             if (Auth::user()->available_email === 1 && Auth::user()->available_vendedor === 1) {
                 $this->setAuditoria('acceso', 'login', $data);
                 Session::put('id', Auth::user()->id);
             } else {
                 if (Auth::user()->available_email === 1) {
                     Session::flash('aviso', 'Debe tener la autorización de su vendedor.');
                 } else {
                     Session::flash('aviso', 'Debe confirmar su correo.');
                 }
                 Auth::logout();
                 return Redirect::back();
             }
         }
         if (Auth::user()->tipo == 'administrador' || Auth::user()->tipo == 'vendedor') {
             $this->setAuditoria('acceso', 'login', $data);
         }
         return Redirect::route('inicio');
     }
     return Redirect::back()->with('login_error', 1)->withInput();
 }
 public function post()
 {
     //step 1: validate input-data
     $validate_data = Input::only('contestant_id', 'keystone');
     $validate_rules = array('contestant_id' => 'required|integer', 'keystone' => 'required|min:8');
     $validator = Validator::make($validate_data, $validate_rules);
     if ($validator->fails()) {
         $validate_messages = $validator->messages()->toArray();
         $this->messageController->send($validate_messages, $this::MESSAGE_KEY);
         return Redirect::to('login');
     }
     //step 2: check empty collection from 'contestant_id', bcs it may not exist
     $contestant = Contestant::find(Input::get('contestant_id'));
     if (!$contestant) {
         $this->messageController->send(array('contestant_id' => ['contestant_id:wrong']), $this::MESSAGE_KEY);
         return Redirect::to('login');
     }
     //step 3: compare hashed-value, if equal, allow login
     //what we get after find is a 'collection', not a Contestant's instance, so fetch it, first()
     if (Hash::check(Input::get('keystone'), $contestant->keystone)) {
         Auth::login($contestant);
         if ($contestant->id == 1) {
             //admin after 'login' refer go to 'admin' page
             return Redirect::to('admin');
         } else {
             //contestant after 'login' refer goto 'test' page
             return Redirect::to('test');
         }
     } else {
         $this->messageController->send(array('keystone' => ['keystone:wrong']), $this::MESSAGE_KEY);
     }
     //as a fall-back, return to login
     return Redirect::to('login');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $this->loginForm->validate($input = Input::only('email', 'password'));
     try {
         Sentry::authenticate($input, true);
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.mgs_invalid_credential'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_not_activated'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_suspended'), 'url' => '');
         return Response::json($mjs);
     }
     // Logged in successfully - redirect based on type of user
     $user = Sentry::getUser();
     $admin = Sentry::findGroupByName('Admins');
     $users = Sentry::findGroupByName('Patients');
     $doctors = Sentry::findGroupByName('Doctors');
     $company = Sentry::findGroupByName('Clinics');
     $recepcion = Sentry::findGroupByName('Receptionist');
     if ($user->inGroup($admin)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/admin');
         return Response::json($mjs);
     } elseif ($user->inGroup($company) or $user->inGroup($recepcion)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/clinic');
         return Response::json($mjs);
     } elseif ($user->inGroup($doctors)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/doctor');
         return Response::json($mjs);
     } elseif ($user->inGroup($users)) {
         return Redirect::to(url());
     }
 }
 public function store()
 {
     if (Auth::attempt(Input::only('username', 'password'))) {
         return "Welcome " . Auth::user()->username;
     }
     return Redirect::back()->withInput();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Auth::attempt(Input::only('email', 'password'))) {
         return Redirect::route('portfolio.index')->withMessage('Welcome, ' . Auth::user()->name)->withFlash_type('success');
     }
     return Redirect::route('sessions.create')->with('message', 'Failed! Check password: justdoit')->with('flash_type', 'alert')->withInput();
 }
 /**
  * Store a newly created conversation in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('users' => 'required|array', 'body' => 'required');
     $validator = Validator::make(Input::only('users', 'body'), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     // Create Conversation
     $params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
     $conversation = Conversation::create($params);
     $conversation->users()->attach(Input::get('users'));
     $conversation->users()->attach(array(Auth::user()->id));
     // Create Message
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach (Input::get('users') as $user_id) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
         // Publish Data To Redis
         $data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
         Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     return Redirect::route('chat.index', array('conversation', $conversation->name));
 }
Example #16
0
 public function store()
 {
     $data = \Input::only(['file']);
     $path = public_path() . '/uploads/files/';
     \FilesHelper::storeFileInPath($path, $data['file']);
     return \Redirect::route('dev.files.index');
 }
 /**
  * Account sign in form processing.
  *
  * @return Redirect
  */
 public function postSignin()
 {
     $this->beforeFilter('csrf', array('on' => 'post'));
     // Declare the rules for the form validation
     $rules = array('email' => 'required|email', 'password' => 'required|between:3,32');
     // Create a new validator instance from our validation rules
     $validator = Validator::make(Input::all(), $rules);
     // If validation fails, we'll exit the operation now.
     if ($validator->fails()) {
         // Ooops.. something went wrong
         return Redirect::route('signin')->withInput()->withErrors($validator);
     }
     try {
         // Try to log the user in
         $user = Sentry::authenticate(Input::only('email', 'password'), Input::get('remember-me', 0));
         // Get the page we were before
         //$redirect = Session::get('loginRedirect', 'account');
         // Unset the page we were before from the session
         //Session::forget('loginRedirect');
         // Redirect to the users page
         return Redirect::route('signin')->with('success', Lang::get('auth/message.signin.success'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $this->messageBag->add('email', Lang::get('auth/message.account_not_found'));
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $this->messageBag->add('email', Lang::get('auth/message.account_not_activated'));
     }
     // Ooops.. something went wrong
     return Redirect::route('signin')->withInput()->withErrors($this->messageBag);
 }
 /**
  * Update a user
  *
  * @param $user_id
  * @return Response
  */
 public function update($user_id)
 {
     $input = Input::only('email', 'name', 'password');
     $user = User::findOrFail($user_id);
     $user->update($input);
     return Response::json(['success' => true, 'data' => $user]);
 }
Example #19
0
 /**
  * Save a new status
  *
  * @return Response
  */
 public function store()
 {
     $this->publishStatusForm->validate(Input::only('body'));
     $this->execute(new PublishStatusCommand(Input::get('body'), Auth::user()->id));
     Flash::message('Your status has been updated!');
     return Redirect::refresh();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $filters = array_filter(Input::only('specialty', 'district', 'municipality', 'city', 'type', 'financing', 'search'));
     $filters_data = School::listFilters();
     $schools_data = School::filterSchools($filters)->paginate(16);
     return View::make('list')->with('filters', $filters_data)->with('schools', $schools_data);
 }
Example #21
0
 public function postLogin()
 {
     if (Auth::attempt(Input::only('email', 'password'), TRUE)) {
         return Auth::user();
     }
     return Response::make(['message' => 'Wrong credentials'], 500);
 }
 /**
  * 특정 회원의 알람을 업데이트함.
  * @param String membertoken
  * @param Integer alarmseq
  * @return Array
  */
 public function updateAlarm($membertoken, $alarmseq)
 {
     // 멤버 토큰을 통해 멤버 가져옴.
     $memberToken = Membertoken::where('token', $membertoken)->first();
     $member = $memberToken->member()->first();
     // 유효성 검사
     $rules = ['isrepeat' => Alarm::CONSTRAINT_ISREPEAT, 'waketime' => Alarm::CONSTRAINT_WAKETIME, 'waketime2' => Alarm::CONSTRAINT_WAKETIME, 'repeatday' => Alarm::CONSTRAINT_REPEATDAY];
     $validator = Validator::make(Input::only('isrepeat', 'waketime', 'waketime2', 'repeatday'), $rules);
     if ($validator->fails()) {
         return Utils::result(Utils::CANNOT_PASS_VALIDATOR, true);
     }
     $memberAlarm = Alarm::find($alarmseq);
     // 알람 업데이트
     if (isset($memberAlarm)) {
         if ($memberAlarm->memberSeq == $member->seq) {
             $memberAlarm->repeat_day = Input::get('repeatday');
             $memberAlarm->isrepeat = Input::get('isrepeat');
             $memberAlarm->waketime = Input::get('waketime');
             $memberAlarm->waketime2 = Input::get('waketime2');
             $affectedRow = $memberAlarm->update();
             return Utils::result($affectedRow);
         }
     }
     return Utils::result(Utils::CANNOT_FIND_ALARM, true);
 }
Example #23
0
 public function store()
 {
     $article = new Article();
     $article->fill(\Input::only(['title', 'content']));
     $article->save();
     return redirect('/');
 }
Example #24
0
 public function resetAction()
 {
     // Fetch all request data.
     $data = Input::only('email', 'password', 'password_confirmation', 'pass_code');
     // Build the validation constraint set.
     $rules = array('email' => array('required'), 'password' => array('required', 'confirmed', 'min:5'));
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $user = Sentry::findUserByLogin(Input::get('email'));
         // Check if the reset password code is valid
         if ($user->checkResetPasswordCode(Input::get('pass_code'))) {
             // Attempt to reset the user password
             if ($user->attemptResetPassword(Input::get('pass_code'), Input::get('password'))) {
                 $user->reset_password_code = '';
                 $user->save();
                 return Redirect::to('/login')->with('global_success', 'Password has been set. You can now sign in with your new password.');
             } else {
                 return Redirect::to('/reset')->with('global_error', 'System couldn\'t change your password. Please try again and if situation repeats, report to support.');
             }
         } else {
             return Redirect::to('/request')->with('global_error', 'Your reset code doesn\'t match. It may be corrupted or outdated. Please make a new request.');
         }
     }
     return Redirect::to('/reset/' . Input::get('pass_code'))->withErrors($validator)->with('message', 'Validation Errors!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::only(['name', 'rank', 'email', 'myMessage', 'g-recaptcha-response']);
     $google_url = "https://www.google.com/recaptcha/api/siteverify";
     $secret = Config::get('recaptcha.secret_key');
     $url = $google_url . "?secret=" . $secret . "&response=" . $data['g-recaptcha-response'];
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_TIMEOUT, 10);
     curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");
     $curlData = curl_exec($curl);
     curl_close($curl);
     $response = json_decode($curlData, true);
     if ($response['success'] == true) {
         $rules = array('name' => 'required|min:3|max:100', 'rank' => 'required|min:3|max:50', 'email' => 'required|email|unique:users|unique:invitations', 'myMessage' => 'required|min:5|max:300');
         $validator = Validator::make($data, $rules);
         if ($validator->fails()) {
             return Redirect::route('admin.request.index')->withErrors($validator->messages());
         } else {
             Mail::send('emails.auth.request', $data, function ($message) {
                 $message->to('*****@*****.**', 'РегистърБГ')->subject('Нова заявка за покана в РегистърБГ');
                 $message->to('*****@*****.**', 'РегистърБГ')->subject('Нова заявка за покана в РегистърБГ');
             });
             if (count(Mail::failures()) > 0) {
                 return Redirect::route('admin.request.index')->withErrors(array('mainError' => 'Възникна грешка при изпращане на имейл. Моля опитайте по-късно.'));
             }
             return Redirect::route('admin.request.index')->withErrors(array('mainSuccess' => 'Заявката е успшно изпратена. Възможно най-бързо ще получите обратна връзка.'));
         }
     }
     return Redirect::route('admin.request.index')->withErrors(array('g-recaptcha-response' => 'Моля потвърдете, че не сте робот.'));
     /*return Redirect::route('admin.index');*/
 }
Example #26
0
 public function createRegistro()
 {
     $usuario = $this->usuariosRepo->newUsuario();
     $token = md5(Input::only('email')['email'] . 'tokenmicai');
     $usuario->token = $token;
     $this->data = Input::all();
     // 1 -> Vendedor de la Foraneos/Nacionales/Extranjeros
     // 3 -> Vendedor de la UNACH
     switch ($this->data['tipo_procedencia']) {
         case 'ittg':
             $this->data['institucion_procedencia'] = 'Instituto Tecnologico de Tuxtla Gutierrez';
             break;
         case 'unach':
             $this->data['vendedor'] = 4;
             $this->data['institucion_procedencia'] = 'Universidad Autonoma de Chiapas';
             break;
         default:
             $this->data['vendedor'] = 3;
             break;
     }
     $manager = new RegistroManejador($usuario, $this->data);
     $this->data = array_add($this->data, 'token', $token);
     if ($manager->save()) {
         //Email de confirmacion
         Mail::send('emails/confirmationEmail', $this->data, function ($message) {
             $message->subject('Correo de confirmación');
             $message->from('*****@*****.**', 'MICAI');
             $message->to($this->data['email']);
         });
         Session::flash('aviso', 'Usuario registrado corréctamente. Para continuar con tu registro activa tu cuenta desde tu correo');
         return Redirect::route('inicio');
     }
     return Redirect::back()->withInput()->withErrors($manager->getErrors());
 }
Example #27
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::only('email', 'username', 'password');
     $rules = array('email' => 'required|email|unique:users,email,' . Auth::user()->id . ',id,deleted_at,NULL,status,' . Auth::user()->status . '');
     if ($input['password']) {
         $rules['password'] = '******';
     }
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'user', 'errors' => $v, 'input' => TRUE));
     }
     if ($input['password'] && $id && Auth::user()->id == $id) {
         $user = user::find($id);
         //$user->username = $input['username'];
         $user->email = $input['email'];
         if ($input['password']) {
             $user->password = Hash::make($input['password']);
             Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
         }
         $user->save();
         return Output::push(array('path' => 'user', 'errors' => 'Change Password Successfully', 'messages' => array('success', _('User data has been saved')), 'input' => TRUE));
     } else {
         return Output::push(array('path' => 'user', 'errors' => 'Unable to update user', 'messages' => array('fail', _('Unable to update user')), 'input' => TRUE));
     }
 }
Example #28
0
 public function store()
 {
     $rules = ['email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6|max:80'];
     $validator = Validator::make(Input::only('email', 'password', 'password_confirmation'), $rules);
     // captcha instance of the example page
     $captcha = $this->getExampleCaptchaInstance();
     // validate the user-entered Captcha code when the form is submitted
     $code = Input::get('CaptchaCode');
     $isHuman = $captcha->Validate($code);
     if ($isHuman) {
         // TODO: Captcha validation passed, perform protected  action
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         }
         $confirmation_code = str_random(30);
         Mail::send('emails.verify', compact('confirmation_code'), function ($message) {
             $message->to(Input::get('email'), Input::get('email'))->subject('Verify your email address');
         });
         User::create(['email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'confirmation_code' => $confirmation_code]);
         Flash::message('Thanks for signing up! Please check your email!');
         return Redirect::route('sessions.create');
     } else {
         // TODO: Captcha validation failed, show error message
         return Redirect::back()->withInput()->withErrors(['credentials' => 'Captcha was wrong']);
     }
 }
Example #29
0
 public function store()
 {
     if (Auth::attempt(Input::only('username', 'password'))) {
         return Redirect::route('users.show', Auth::user()->username);
     }
     return Redirect::back()->withInput()->withErrors(array('password' => 'Invalid Password or username'));
 }
Example #30
0
 /**
  * @return string
  * User Registration.
  */
 public function postRegister()
 {
     $input = Input::only('firstname', 'lastname', 'email', 'password', 'confirm_password');
     try {
         $rules = array('firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'email' => 'required|email|unique:users', 'password' => 'required|min:4', 'confirm_password' => 'required|same:password');
         $messages = array('required' => 'Het :attribute veld is verplicht in te vullen.', 'min' => 'Het :attribute veld moet minstens 2 karakters bevatten.');
         $validator = Validator::make($input, $rules, $messages);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         } else {
             unset($input['confirm_password']);
             $user = Sentry::register($input);
             $activationCode = $user->getActivationCode();
             $data = array('token' => $activationCode);
             Mail::send('emails.auth.welcome', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', 'Site Admin');
                 $message->to($user['email'], $user['first_name'], $user['last_name'])->subject('Welcome to My Laravel app!');
             });
             if (count(Mail::failures()) > 0) {
                 $errors = 'Failed to send password reset email, please try again.';
             }
             if ($user) {
                 return Redirect::action('AuthController@login');
             }
         }
     } catch (Sentry\SentryException $e) {
         // Create custom error msgs.
     }
 }