Exemplo n.º 1
1
 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");
 }
Exemplo n.º 2
0
 public function extractKeyAndUser(Request $request)
 {
     $apiKey = $request->header('Authorization');
     if (!$apiKey) {
         throw new InvalidAuthException('No Authorization header provided.');
     }
     if (strpos($apiKey, 'Basic ') === 0) {
         $apiKey = substr($apiKey, 5, strlen($apiKey));
     }
     $parts = explode(':', $apiKey);
     if (sizeof($parts) != 2) {
         throw new InvalidAuthException('Invalid Authorization header provided. It has to be user:code');
     }
     $user = User::where('email', trim($parts[0]))->first();
     if ($user) {
         try {
             $key = new PrivateKey($user->rsaKey->private);
             $pass = Crypt::decrypt(trim($parts[1]));
             $key->unlock($pass);
             return ['user' => $user, 'key' => $key];
         } catch (\Exception $e) {
             throw new InvalidAuthException($e->getMessage());
         }
     }
     return null;
 }
 /**
  * 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);
 }
Exemplo n.º 4
0
Arquivo: Admin.php Projeto: vizo/Core
 /**
  * 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);
 }
Exemplo n.º 5
0
 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');
 }
Exemplo n.º 7
0
 /**
  * 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.');
     }
 }
Exemplo n.º 8
0
 public function match($store)
 {
     $cookie = Cookie::get('store');
     if ($cookie && ($store_id = Crypt::decrypt($cookie))) {
         return $store->find($store_id);
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * Get refresh token from session and decrypt it.
  *
  * @return mixed
  */
 public function getRefreshToken()
 {
     if ($this->has('refresh_token')) {
         $token = $this->get('refresh_token');
         return Crypt::decrypt($token);
     }
     throw new MissingRefreshTokenException(sprintf('No refresh token stored in current session. Verify you have added refresh_token to your scope items on your connected app settings in Salesforce.'));
 }
Exemplo n.º 10
0
function decrypt($value)
{
    try {
        return Crypt::decrypt($value);
    } catch (DecryptException $e) {
        //
    }
}
Exemplo n.º 11
0
 /**
  * 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();
 }
Exemplo n.º 12
0
 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');
 }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 /**
  * 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);
 }
Exemplo n.º 15
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::guest()) {
         Auth::onceUsingId(Crypt::decrypt(request()->input('_user')));
     }
     if (Auth::user()) {
         return $next($request);
     } else {
         Response::make('No Autorizado', 401);
     }
 }
Exemplo n.º 16
0
 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');
 }
Exemplo n.º 17
0
 private function replaceData($data)
 {
     $data['ip'] = getIp();
     $data['ratingspage_id'] = $data['id'];
     $data['ratingspage_type'] = str_replace("\\", "_", Crypt::decrypt($data['model']));
     $data['rating'] = $data['value'];
     if (Sentry::check()) {
         $data['user_id'] = Sentry::getUser()->id;
     }
     return $data;
 }
Exemplo n.º 18
0
 /**
  * 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');
 }
Exemplo n.º 19
0
 public function downloadAReportTask(Request $request)
 {
     // get parameters from url route
     $parameters = $request->route()->parameters();
     $reportTask = ReportTask::builder()->find(Crypt::decrypt($parameters['token']));
     $filename = Crypt::decrypt($parameters['filename']);
     if ($reportTask === null) {
         abort(404);
     }
     return response()->download(storage_path('exports') . '/' . $filename . '.' . $reportTask->extension_file_023);
 }
 /**
  * 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'));
 }
Exemplo n.º 21
0
 /**
  * 更新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;
 }
Exemplo n.º 22
0
 /**
  * Extending Laravel Validator (http://laravel.com/docs/validation#custom-validation-rules)
  */
 public function validate($attribute, $value, $parameters, $validator)
 {
     // Laravel will throw an uncaught exception if the value is empty
     // We will try and catch it to make it easier on users.
     try {
         $value = Crypt::decrypt($value);
     } catch (\Illuminate\Encryption\DecryptException $exception) {
         return false;
     }
     // The current time should be greater than the time the form was built + the speed option
     return is_numeric($value) && time() > $value + $parameters[0];
 }
Exemplo n.º 23
0
 public function modelDecrypterCallback($array)
 {
     $new_array = [];
     foreach ($array as $key => $value) {
         if (in_array($key, $this->encryptable_array)) {
             $new_array[$key] = Crypt::decrypt($value);
         } else {
             $new_array[$key] = $value;
         }
     }
     return $new_array;
 }
Exemplo n.º 24
0
 public function doAddComment()
 {
     parse_str(Input::get('data'), $data);
     if (isset($data['id_page'])) {
         $data['commentpage_type'] = Crypt::decrypt($data['commentable']);
         $data['commentpage_id'] = $data['id_page'];
         if (Sentry::check()) {
             $data['user_id'] = Sentry::getUser()->id;
             $data['name'] = Sentry::getUser()->getFullName();
         }
         Comment::create($data);
         return $this->listCommetns($data['commentpage_type'], $data['id_page']);
     }
 }
 /**
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getActivate()
 {
     try {
         $token = Input::get('token');
         $email = Input::get('email');
         $id = Crypt::decrypt($token);
         $user = User::where(['id' => $id, 'email' => $email])->firstOrFail();
         $user->active = true;
         $user->save();
         Auth::loginUsingId($user->id);
         return Redirect::route('home');
     } catch (\Exception $e) {
         return Redirect::route('login');
     }
 }
 public function getFind($id)
 {
     $data = $this->find($id);
     if ($data != null) {
         $data->package_id = Crypt::decrypt($data->package_id);
         $data->source = Crypt::decrypt($data->source);
         $data->destination = Crypt::decrypt($data->destination);
         $data->port = Crypt::decrypt($data->port);
         $data->protocol = Crypt::decrypt($data->protocol);
         $data->data = Crypt::decrypt($data->data);
     } else {
         $data = new Package();
     }
     return $data;
 }
Exemplo n.º 27
0
 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);
     }
 }
Exemplo n.º 28
0
 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;
 }
Exemplo n.º 29
0
 public function onOpen(ConnectionInterface $conn)
 {
     // Store the new connection to send messages to later
     $this->clients->attach($conn);
     $session = (new SessionManager(App::getInstance()))->driver();
     $cookies = $conn->WebSocket->request->getCookies();
     $laravelCookie = urldecode($cookies[Config::get('session.cookie')]);
     $idSession = Crypt::decrypt($laravelCookie);
     $session->setId($idSession);
     $session->start();
     $userId = $session->get(Auth::getName());
     $user = User::find($userId);
     $conn->userId = $userId;
     $conn->isAdmin = $user->is_admin === true;
     echo "New connection! ({$conn->resourceId}), {$userId}\n";
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->app->singleton(\Google_Client::class, function ($app) {
         $client = new \Google_Client();
         $client->setApplicationName('GDrive Comments');
         $client->setClientId(config('services.google.client_id'));
         $client->setClientSecret(config('services.google.client_secret'));
         $client->setAccessToken(Crypt::decrypt($app['auth']->user()->token));
         return $client;
     });
     $this->app->singleton(\Google_Service_Drive::class, function ($app) {
         if ($app->environment() === 'testing') {
             return new MockedGoogleServiceDrive();
         }
         $drive = new \Google_Service_Drive($app[\Google_Client::class]);
         return $drive;
     });
 }