Exemplo n.º 1
0
 /**
  * Persist the changes.
  *
  * @param PasswordFolder $folder
  *
  * @return bool
  */
 public function persist(PasswordFolder $folder)
 {
     $folder->user_id = Auth::user()->id;
     $folder->locked = true;
     $folder->uuid = uuid();
     $folder->pin = $this->input('pin');
     return $folder->save();
 }
Exemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $folder = $this->folder->where('user_id', auth()->user()->id)->first();
     if ($folder instanceof PasswordFolder) {
         // If a folder already exists, the user is trying to access
         // setup again. We'll redirect them to an 'invalid' page.
         return redirect()->route('passwords.setup.invalid');
     } else {
         // Looks like the user doesn't have a password folder
         // yet. We'll let them proceed into setup.
         return $next($request);
     }
 }
Exemplo n.º 3
0
 public function test_passwords_delete()
 {
     $this->test_access_after_setup();
     $user = User::first();
     $folder = PasswordFolder::where('user_id', $user->id)->first();
     $password = factory(Password::class)->create(['folder_id' => $folder->id]);
     $this->actingAs($password->folder->user);
     $token = ['_token' => \Session::token()];
     $this->delete(route('passwords.destroy', [$password->id]), $token);
     $this->assertRedirectedToRoute('passwords.index');
 }