コード例 #1
0
ファイル: SetupRequest.php プロジェクト: stevebauman/ithub
 /**
  * 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();
 }
コード例 #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);
     }
 }
コード例 #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');
 }