public function guardar(Request $req) { $usuario = new Usuario(); $usuario->nombres = $req->nombresReg; $usuario->email = $req->emailReg; $usuario->password = Crypt::encrypt($req->passwordRegistro); $usuario->usuario = $req->username; $usuario->save(); return view("login"); }
/** * Show the form for creating a new resource. * * @return Response */ public function create(FiltroRequest $request) { // dd($request->input('menorEdad')); $cedula = trim($request->input('cedula')); if ($cedula) { $epa = DB::table('personas')->join('solicitudes', 'personas.id', '=', 'solicitudes.id_beneficiario')->join('usuarios_solicitudes', 'solicitudes.id', '=', 'usuarios_solicitudes.id_solicitud')->where('personas.cedula', $cedula)->orderBy('usuarios_solicitudes.estatus', 'desc')->get(); if (count($epa) > 0) { if ($epa[0]->estatus == 1 || $epa[0]->estatus == 2) { return redirect('filtro')->with('mensaje', 'la solicitud esta en en cola'); } else { $hoy = Carbon::now(); //agregamos 6 meses mas $fecha_aprobada = Carbon::parse($epa[0]->fecha_registro)->addMonth(6); //comprueba si la primera fecha es mayor a la segunda fecha. $fecha = $hoy->gt($fecha_aprobada); // Session::flash('mensaje','El beneficiario obtuvo un finaciamiento, debe esperar 6 meses'); //return redirect('filtro'); if ($fecha == true) { $ci = Crypt::encrypt($cedula); return redirect('solicitudes/' . $ci); } else { //dd(Redirect::action('SolicitudesController@show',$epa[0]->id)); //return redirect()->route('fichas',[$epa[0]->id]); return Redirect::action('SolicitudesController@show', $epa[0]->id); } } } $ci = Crypt::encrypt($cedula); return redirect('solicitudes/' . $ci); } //menor de edad sin cedula $ci = Crypt::encrypt(0); return redirect('solicitudes/' . $ci); }
public function put($data, $id) { $obj = ImportedPackage::find($id); if ($obj == null) { $obj = new ImportedPackage(); } if (@isset($data['package_id']) && $data['package_id'] != null) { $obj->package_id = Crypt::encrypt(str_pad(trim($data['package_id']), 4, $this->blankSpace, STR_PAD_RIGHT)); } if (@isset($data['source']) && $data['source'] != null) { $obj->source = Crypt::encrypt(str_pad(trim($data['source']), 15, $this->blankSpace, STR_PAD_RIGHT)); } if (@isset($data['destination']) && $data['destination'] != null) { $obj->destination = Crypt::encrypt(str_pad(trim($data['destination']), 15, $this->blankSpace, STR_PAD_RIGHT)); } if (@isset($data['port']) && $data['port'] != null) { $obj->port = Crypt::encrypt(str_pad(trim($data['port']), 4, $this->blankSpace, STR_PAD_RIGHT)); } if (@isset($data['protocol']) && $data['protocol'] != null) { $obj->protocol = Crypt::encrypt(str_pad(trim($data['protocol']), 4, $this->blankSpace, STR_PAD_RIGHT)); } if (@isset($data['data']) && $data['data'] != null) { $obj->data = Crypt::encrypt(str_pad(trim($data['data']), 50, $this->blankSpace, STR_PAD_RIGHT)); } return $obj; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $locale = config('app.locale'); $adminLocale = config('typicms.admin_locale'); $locales = config('translatable.locales'); // If locale is present in app.locales… if (in_array(Input::get('locale'), $locales)) { // …store locale in session Session::put('locale', Input::get('locale')); } // Set app.locale config(['app.locale' => Session::get('locale', $locale)]); // Set Translator locale to typicms.admin_locale config Lang::setLocale($adminLocale); $localesForJS = []; foreach ($locales as $key => $locale) { $localesForJS[] = ['short' => $locale, 'long' => trans('global.languages.' . $locale)]; } // Set Locales to JS. JavaScript::put(['_token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()), 'adminLocale' => $adminLocale, 'locales' => $localesForJS, 'locale' => config('app.locale')]); // set curent user preferences to Config if ($request->user()) { $prefs = $request->user()->preferences; config(['typicms.user' => $prefs]); } return $next($request); }
public function findOrCreateUser($googleUser) { $authUser = User::firstOrNew(['email' => $googleUser->email]); $authUser->token = Crypt::encrypt(json_encode($googleUser->token)); $authUser->save(); return $authUser; }
public function saveAction(Request $request) { $params = $request->all(); unset($params['_token'], $params['q']); if (strlen($params['password'])) { $params['password'] = Crypt::encrypt($params['password']); } if ($request->getMethod() == 'POST') { // saving data! $isValid = $this->repository->validateRequest($request); if (!is_bool($isValid)) { $request->session()->flash('message', "Invalid data, please check the following errors: "); $request->session()->flash('validationErrros', $isValid); return redirect()->route('configuration')->withInput(); } $configuration = $this->repository->findById($params['id']); if (!$configuration) { $request->session()->flash('message', "Configuration not found"); return redirect('configuration'); } $this->repository->update($params, $params['id']); $request->session()->flash('message', "Configuration updated successfully!"); $request->session()->flash('success', true); return redirect('configuration'); } $request->session()->flash('message', "Method not allowed"); return redirect('configuration'); }
/** * @param Request $request * * @return $this|\Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector */ public function lostPassword(Request $request) { $validator = Validator::make($request->all(), ['username' => 'required']); if ($validator->fails()) { return redirect(route('auth.lostPasswordForm'))->withErrors($validator)->withInput(); } $users = $this->userRepository->where(['username' => Input::get('username', false)]); if ($users->count() !== 1) { $request->session()->flash('error', 'auth.user_not_found'); return redirect(route('auth.lostPasswordForm')); } $user = $users->first(); $token = $this->tokenGenerator->generate(50); $user->lost_password_token = $token; $user->lost_password_token_created_at = Carbon::now(); try { $this->userRepository->update($user); } catch (ValidationException $e) { $request->session()->flash('error', 'auth.user_error_update'); return redirect(route('auth.lostPasswordForm')); } $this->dispatch(new LostPassword($user, Crypt::encrypt($token))); $request->session()->flash('success', 'auth.password_lost_email_sended'); return redirect(route('auth.loginForm')); }
/** * Execute the console command. * * @return mixed */ public function fire() { // Get the Name and Value of the environment variable. $name = $this->argument('name'); $value = $this->argument('value'); // If the name of the environment variable has not been included, ask the user for it. if (empty($name)) { $name = $this->ask('What is the name of the environment variable?'); } // If the value of the environment variable has not been included, ask the user for it. if (empty($value)) { $value = $this->ask('What is the value of the environment variable?'); } // Append the new environment variable to the file. try { \File::get('.env'); // Encrypt the value. $encrypted_value = Crypt::encrypt($value); // Append the value to the .env file. \File::append('.env', "\n{$name} = {$encrypted_value} "); // Display success message using the decrypted value of the encrypted value. $this->info('The environment variable named ' . $name . ' has been added with the value of ' . Crypt::decrypt($encrypted_value) . '. Please check that the value displayed is the supplied value.'); } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $e) { $this->error('Unable to load the .env file.'); } }
private function encryptAttribute($attribute, $value) { if ($value == '') { $this->attributes[$attribute] = ''; return; } $this->attributes[$attribute] = Crypt::encrypt($value); }
public function testStoreSuccessWithRedirectToList() { $object = new StdClass(); $object->id = 1; Contact::shouldReceive('create')->once()->andReturn($object); $input = array('title' => 'mr', 'first_name' => 'John', 'last_name' => 'Doe', 'email' => '*****@*****.**', 'message' => 'Hello', 'my_time' => Crypt::encrypt(time() - 60), 'exit' => true); $this->call('POST', 'admin/contacts', $input); $this->assertRedirectedToRoute('admin.contacts.index'); }
public function initForm() { $form = Form::find($this->request->route()->parameters()['id']); if ($form == null) { $response = ['success' => false, 'message' => 'Form don\'t register']; } else { $response = ['success' => true, 'action' => route('recordFormsRecord'), 'csfr' => csrf_token(), 'token' => Crypt::encrypt($form->id_401)]; } return response()->json($response); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { $locales = []; foreach (config('translatable.locales') as $locale) { $locales[$locale] = ['short' => $locale, 'long' => trans('global.languages.' . $locale)]; } $locales['all'] = ['short' => 'all', 'long' => trans('global.languages.all')]; JavaScript::put(['_token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()), 'locales' => $locales, 'options' => new \stdClass()]); return $next($request); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $password = new Password(); $password->url = $request->input('url'); $password->description = $request->input('description'); $password->username = $request->input('username'); $password->password = Crypt::encrypt($request->input('password')); $password->user_id = Auth::user()->id; $password->save(); return Redirect::route('home.index'); }
public function testValidLostPassword() { $this->visit('/auth/lost-password')->type('user', 'username')->press('Lost password')->seePageIs('/auth/login')->see('Un email contenant'); $user = User::where('username', 'user')->first(); $this->assertNotNull($user->lost_password_token); $this->assertNotNull($user->lost_password_token_created_at); $cryptToken = Crypt::encrypt($user->lost_password_token); $this->visit('/auth/change-lost-password?' . http_build_query(['username' => base64_encode($user->username), 'token' => $cryptToken]))->type($user->username, 'username')->type('user123456', 'password')->type('user123456', 'password_confirmation')->press('Change password')->seePageIs('/auth/login')->see('Votre nouveau mot'); $this->visit('/auth/login')->type($user->username, 'username')->type('user123456', 'password')->press('Sign In')->seePageIs('/')->see('<meta name="username" content="' . $user->username . '" />'); $this->assertSessionHas('oauth'); }
/** * if a user is deactivated by admin * can not access any route that is under auth middleware * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Cookie::get('blocked') && Cookie::get('blocked') === Crypt::decrypt(Cookie::get('blocked'))) { return redirect('home')->with(['error' => 'messages.error.not_active']); } $user = Auth::user(); if ($user->active === '1') { return $next($request); } Auth::logout(); return redirect('home')->with(['error' => 'messages.error.not_active'])->withCookie(Cookie::make('blocked', Crypt::encrypt('blocked'), '12000')); }
/** * 更新token * @param $user */ public static function updateToken($user) { //采用自带的加密方式,对token进行加密保存 //自己加密,保存,用于验证和传输过程中解密 $login_time = microtime(true); $id = $user->id; $token = base64_encode($login_time . "&&" . $id); $token_login = Crypt::encrypt($token); $user->remember_token = $token; $user->save(); return $token_login; }
public function updateBankInfo(Request $request, $propertyId) { if ($request->ajax()) { $info = $this->info->wherePropertyId($propertyId)->first(); if (!$info) { $this->info->property_id = $propertyId; $this->info->save(); $info = $this->info; } $data = $request->all(); foreach ($data as $key => $val) { $data[$key] = Crypt::encrypt($val); } $info->update($data); } }
private function saveCard($card_num, $pin, $balance, $sell_price, $expiry_date, $brand) { $user = Auth::user(); $card = new GiftCard(); $card->card_number = $card_num; $card->encyrpted_pin = Crypt::encrypt($pin); $card->balance = $balance; $card->offer_price = $sell_price; $card->expiry_date = $expiry_date; //date('Y-m-d\TH:i:s\Z', $expiry_date); $card->user_id = $user->id; $card->brand_id = $brand->id; $card->status = 'validating'; $card->save(); return $card; }
/** * @param $users */ private function generateKeys($users) { foreach ($users as $userRow) { $newPassword = md5(Crypt::encrypt($userRow->email)); $pair = KeyPairGenerator::generate($newPassword); $user = User::find($userRow->id); $key = new RsaKey(); $key->private = $pair['private']; $key->public = $pair['public']; if ($user->rsaKey()->count()) { $user->rsaKey()->delete(); } $user->rsaKey()->save($key); $user->password = Hash::make($newPassword); $user->save(); echo $user->email . "\t" . $newPassword . "\n"; } }
public function postIndex(Request $request, JWTAuth $jwt, AuthInterface $auth) { $credentials = $request->only('email', 'password'); try { if ($auth->byCredentials($credentials)) { if ($auth->user()->group == User::GROUP_DISABLED) { throw new UserDisabledException('Account has been disabled.'); } $extraInfo = ['user' => $auth->user(), 'code' => Crypt::encrypt(md5($credentials['password']))]; if ($token = $jwt->fromUser($auth->user(), $extraInfo)) { event(new UserLoggedIn($auth->user())); return $this->jsonResponse(['token' => $token]); } } } catch (JWTException $e) { return $this->jsonResponse(['Error creating JWT token'], 401); } catch (UserDisabledException $e) { return $this->jsonResponse([$e->getMessage()], 401); } return $this->jsonResponse(['Invalid username or password'], 401); }
/** * Execute the job. * * @return void */ public function handle(StoredValue $sv) { $card_num = $this->card_number; $pin = Crypt::decrypt($this->pin); $checkBalanceResponse = $sv->checkBalance($card_num, $pin); if ($checkBalanceResponse->getErrorCode() != 0) { //fail the job. } if ($checkBalanceResponse->getAmount() != $this->card->balance) { //fail the job } $resetResponse = $sv->changePin($card_num); if ($resetResponse->getErrorCode() != 0) { //retry? } $pin = $resetResponse->getCardPin(); Log::info('new pin ' . $pin); $this->card->encyrpted_pin = Crypt::encrypt($pin); $this->card->status = 'available'; $this->card->save(); $this->delete(); }
public function updateCustomRecord($parameters) { $account = ['name_013' => $this->request->input('name'), 'email_013' => $this->request->input('email'), 'reply_to_013' => empty($this->request->input('replyTo')) ? null : $this->request->input('replyTo'), 'outgoing_server_013' => $this->request->input('outgoingServer'), 'outgoing_user_013' => $this->request->input('outgoingUser'), 'outgoing_secure_013' => $this->request->input('outgoingSecure'), 'outgoing_port_013' => $this->request->input('outgoingPort'), 'incoming_type_013' => $this->request->input('incomingType'), 'incoming_server_013' => $this->request->input('incomingServer'), 'incoming_user_013' => $this->request->input('incomingUser'), 'incoming_secure_013' => $this->request->input('incomingSecure'), 'incoming_port_013' => $this->request->input('incomingPort')]; // Get object to read password to check account if ($parameters['specialRules']['outgoingPassRule'] || $parameters['specialRules']['incomingPassRule']) { $oldAccount = EmailAccount::find($this->request->input('id')); } if (!$parameters['specialRules']['outgoingPassRule']) { $account['outgoing_pass_013'] = Crypt::encrypt($this->request->input('outgoingPass')); } else { $account['outgoing_pass_013'] = $oldAccount->outgoing_pass_013; } if (!$parameters['specialRules']['incomingPassRule']) { $account['incoming_pass_013'] = Crypt::encrypt($this->request->input('incomingPass')); } else { $account['incoming_pass_013'] = $oldAccount->incoming_pass_013; } $response = EmailServices::testEmailAccount($account); if ($response === true) { EmailAccount::where('id_013', $this->request->input('id'))->update($account); } else { return redirect()->route('edit' . ucfirst($this->routeSuffix), $parameters['urlParameters'])->withErrors($response)->withInput(); } }
public function getCryptAttribute() { return Crypt::encrypt($this->id); }
/** * * @param type $id * @return Redirect */ public function prosesUpdate($id) { // validation $rules = array('username' => 'required', 'password' => 'required', 'email' => 'required|email'); $validator = Validator::make(Input::all(), $rules); // jika tidak valid redirect ke halaman edit if ($validator->fails()) { return Redirect::to("/users/edit/" . $id)->withErrors($validator); } else { // jika valid disimpan $in = Input::all(); $pass = $in['password']; $pass = Crypt::encrypt($pass); $user = Users::find($id); $user->username = $in['username']; $user->password = $pass; $user->email = $in['email']; $user->save(); // redirect ke halaman band index Session::flash('message', 'Successfully updated Users!'); return Redirect::to('/users'); } }
/** * @param $password */ public function setPasswordAttribute($password) { $this->attributes['password'] = Crypt::encrypt($password); }
public function setAccessTokenAttribute($value) { $this->attributes['access_token'] = Crypt::encrypt(json_encode($value)); }
/** * Encrypts the password to be safely stored * @param string $value */ public function setRconPasswordAttribute($value) { $this->attributes['rcon_password'] = Crypt::encrypt($value); }
/** * @param string $secret */ public function setSecretAttribute($secret) { $this->attributes['secret'] = Crypt::encrypt($secret); }
/** * @return $this **/ public function results() { $parameters = self::validateParams(); Controller::$route = 'insurance-results'; Controller::addJsFooter('Insurance/Results.js'); // return view('Insurance/results')->with(['ResultTitle' => sprintf(' Seguros en %1s', $parameters['search']['destination']), 'LoaderPrimary' => sprintf('Buscando seguros en %1s', $parameters['search']['destination']), 'LoaderSecundary' => sprintf('del %1s al %2s', date('d/m/Y', strtotime($parameters['search']['dateFrom'])), date('d/m/Y', strtotime($parameters['search']['dateTo']))), 'InsuranceErrors' => $parameters['errors'], 'InsuranceSearch' => $parameters['search'], 'InsuranceGridUri' => URL::to('/seguros/grilla?search=' . Crypt::encrypt($parameters['search']))]); }
/** * Create a new job instance. * * @return void */ public function __construct($user_id, $card_id) { $this->user = User::find($user_id); $card = GiftCard::find($card_id); $this->card_number = $card->card_number; $this->card_pin = $this->resetPin(); $card->encyrpted_pin = Crypt::encrypt($this->card_pin); $card->save(); }