Browse Source

add remember me feature

pull/43/head
Damilola Olowookere 7 years ago
parent
commit
ce6705931a
  1. 147
      app/Http/Controllers/Auth/LoginController.php
  2. 3
      composer.json
  3. 467
      composer.lock
  4. 1
      resources/lang/de/auth.php
  5. 1
      resources/lang/en/auth.php
  6. 1
      resources/lang/id/auth.php
  7. 1
      resources/views/auth/login.blade.php

147
app/Http/Controllers/Auth/LoginController.php

@ -2,77 +2,88 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
/**
* Send the response after the user was authenticated.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
flash(trans('auth.welcome', ['name' => $request->user()->name]));
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
}
/**
* Log the user out of the application.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->flush();
$request->session()->regenerate();
flash(trans('auth.logged_out'), 'success');
return redirect(route('auth.login'));
}
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
public function login(Request $request)
{
$credentials = $request->only('email', 'password');
if (\Auth::attempt($credentials, $request->has('remember'))) {
return redirect($this->redirectTo);
} else {
return $this->sendFailedLoginResponse($request);
}
}
/**
* Send the response after the user was authenticated.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
flash(trans('auth.welcome', ['name' => $request->user()->name]));
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
}
/**
* Log the user out of the application.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->flush();
$request->session()->regenerate();
flash(trans('auth.logged_out'), 'success');
return redirect(route('auth.login'));
}
}

3
composer.json

@ -13,7 +13,8 @@
"laravel/framework": "5.7.*",
"luthfi/formfield": "^1.0",
"riskihajar/terbilang": "^1.2",
"spatie/laravel-fractal": "<5.5"
"spatie/laravel-fractal": "<5.5",
"spatie/laravel-medialibrary": "^7.0.0"
},
"require-dev": {

467
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "8586ef2012ae029e563ae45306abb909",
"content-hash": "2c79006b0c9b9c41306539d5f580fb9f",
"packages": [
{
"name": "backup-manager/backup-manager",
@ -891,6 +891,76 @@
"time": "2018-12-04T20:46:45+00:00"
},
{
"name": "intervention/image",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "39eaef720d082ecc54c64bf54541c55f10db546d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/39eaef720d082ecc54c64bf54541c55f10db546d",
"reference": "39eaef720d082ecc54c64bf54541c55f10db546d",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"time": "2019-06-24T14:06:31+00:00"
},
{
"name": "kylekatarnls/update-helper",
"version": "1.1.1",
"source": {
@ -1513,6 +1583,67 @@
"time": "2019-05-10T02:16:43+00:00"
},
{
"name": "league/glide",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/glide.git",
"reference": "a5477e9e822ed57b39861a17092b92553634932d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/glide/zipball/a5477e9e822ed57b39861a17092b92553634932d",
"reference": "a5477e9e822ed57b39861a17092b92553634932d",
"shasum": ""
},
"require": {
"intervention/image": "^2.4",
"league/flysystem": "^1.0",
"php": "^5.5 | ^7.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/php-token-stream": "^1.4",
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"League\\Glide\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Reinink",
"email": "jonathan@reinink.ca",
"homepage": "http://reinink.ca"
}
],
"description": "Wonderfully easy on-demand image manipulation library with an HTTP based API.",
"homepage": "http://glide.thephpleague.com",
"keywords": [
"ImageMagick",
"editing",
"gd",
"image",
"imagick",
"league",
"manipulation",
"processing"
],
"time": "2019-04-03T23:46:42+00:00"
},
{
"name": "luthfi/formfield",
"version": "1.0.8",
"source": {
@ -1565,6 +1696,58 @@
"time": "2019-06-14T02:15:17+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "v0.5.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "95922b6324955974675fd4923f987faa598408af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/95922b6324955974675fd4923f987faa598408af",
"reference": "95922b6324955974675fd4923f987faa598408af",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">= 7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.3"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"time": "2018-02-09T09:26:57+00:00"
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"source": {
@ -2499,6 +2682,109 @@
"time": "2019-05-13T07:08:06+00:00"
},
{
"name": "spatie/image",
"version": "1.7.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/image.git",
"reference": "61fa48fa4cb85eda4ef4f8f20b1c27edd9d38e85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image/zipball/61fa48fa4cb85eda4ef4f8f20b1c27edd9d38e85",
"reference": "61fa48fa4cb85eda4ef4f8f20b1c27edd9d38e85",
"shasum": ""
},
"require": {
"ext-exif": "*",
"league/glide": "^1.4",
"php": "^7.0",
"spatie/image-optimizer": "^1.0",
"spatie/temporary-directory": "^1.0.0",
"symfony/process": "^3.0|^4.0"
},
"require-dev": {
"larapack/dd": "^1.1",
"phpunit/phpunit": "^6.0|^7.0",
"symfony/var-dumper": "^3.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Image\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Manipulate images with an expressive API",
"homepage": "https://github.com/spatie/image",
"keywords": [
"image",
"spatie"
],
"time": "2019-05-13T11:38:22+00:00"
},
{
"name": "spatie/image-optimizer",
"version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/spatie/image-optimizer.git",
"reference": "e62f8b459bee0a880c8976c316e82638a74510b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image-optimizer/zipball/e62f8b459bee0a880c8976c316e82638a74510b5",
"reference": "e62f8b459bee0a880c8976c316e82638a74510b5",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": "^7.2",
"psr/log": "^1.0",
"symfony/process": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"symfony/var-dumper": "^4.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\ImageOptimizer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily optimize images using PHP",
"homepage": "https://github.com/spatie/image-optimizer",
"keywords": [
"image-optimizer",
"spatie"
],
"time": "2019-02-15T12:11:38+00:00"
},
{
"name": "spatie/laravel-fractal",
"version": "5.4.4",
"source": {
@ -2567,6 +2853,185 @@
"time": "2019-02-27T00:32:04+00:00"
},
{
"name": "spatie/laravel-medialibrary",
"version": "7.6.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-medialibrary.git",
"reference": "6ffb8a41e60f024abd35ff47e08628354d6efd0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/6ffb8a41e60f024abd35ff47e08628354d6efd0e",
"reference": "6ffb8a41e60f024abd35ff47e08628354d6efd0e",
"shasum": ""
},
"require": {
"illuminate/bus": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/console": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/pipeline": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"league/flysystem": "^1.0.8",
"maennchen/zipstream-php": "~0.4",
"php": "^7.2",
"spatie/image": "^1.4.0",
"spatie/pdf-to-image": "^1.2",
"spatie/temporary-directory": "^1.1"
},
"conflict": {
"php-ffmpeg/php-ffmpeg": "<0.6.1"
},
"require-dev": {
"doctrine/dbal": "^2.5.2",
"ext-pdo_sqlite": "*",
"guzzlehttp/guzzle": "^6.3",
"league/flysystem-aws-s3-v3": "^1.0.13",
"mockery/mockery": "^1.0.0",
"orchestra/testbench": "~3.8.0",
"phpunit/phpunit": "^8.0",
"spatie/phpunit-snapshot-assertions": "^2.0"
},
"suggest": {
"league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage",
"php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\MediaLibrary\\MediaLibraryServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\MediaLibrary\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://murze.be",
"role": "Developer"
}
],
"description": "Associate files with Eloquent models",
"homepage": "https://github.com/spatie/laravel-medialibrary",
"keywords": [
"cms",
"conversion",
"downloads",
"images",
"laravel",
"laravel-medialibrary",
"media",
"spatie"
],
"time": "2019-02-27T09:31:55+00:00"
},
{
"name": "spatie/pdf-to-image",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/pdf-to-image.git",
"reference": "f33afc92ff7bff272fa6a9ba1cc335e96c57eb26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/f33afc92ff7bff272fa6a9ba1cc335e96c57eb26",
"reference": "f33afc92ff7bff272fa6a9ba1cc335e96c57eb26",
"shasum": ""
},
"require": {
"ext-imagick": "*",
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\PdfToImage\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Convert a pdf to an image",
"homepage": "https://github.com/spatie/pdf-to-image",
"keywords": [
"convert",
"image",
"pdf",
"pdf-to-image",
"spatie"
],
"time": "2018-07-02T09:30:32+00:00"
},
{
"name": "spatie/temporary-directory",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/spatie/temporary-directory.git",
"reference": "5e1799fa2297363ebfb4df296fea90afbd4ef9b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/5e1799fa2297363ebfb4df296fea90afbd4ef9b7",
"reference": "5e1799fa2297363ebfb4df296fea90afbd4ef9b7",
"shasum": ""
},
"require": {
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\TemporaryDirectory\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily create, use and destroy temporary directories",
"homepage": "https://github.com/spatie/temporary-directory",
"keywords": [
"spatie",
"temporary-directory"
],
"time": "2018-04-12T09:34:43+00:00"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.1",
"source": {

1
resources/lang/de/auth.php

@ -19,6 +19,7 @@ return [
'throttle' => 'Zu viele Login Versuche. Bitte probiere es erneut in :seconds Sekunden.',
'logout' => 'Logout',
'logged_out' => 'Sie haben sich ausgeloggt.',
'remember_me' => 'Erinnere dich an mich',
// Password
'change_password' => 'Passwort ändern',

1
resources/lang/en/auth.php

@ -19,6 +19,7 @@ return [
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
'logout' => 'Logout',
'logged_out' => 'You have logged out.',
'remember_me' => 'Remember me',
// Password
'change_password' => 'Change Password',

1
resources/lang/id/auth.php

@ -19,6 +19,7 @@ return [
'throttle' => 'Terlalu banyak usaha masuk. Silahkan coba lagi dalam :seconds detik.',
'logout' => 'Keluar',
'logged_out' => 'Anda telah logout.',
'remember_me' => 'Ingat saya',
// Password
'change_password' => 'Ganti Password',

1
resources/views/auth/login.blade.php

@ -12,6 +12,7 @@
{{ Form::open(['route' => 'auth.login']) }}
{!! FormField::email('email', ['label' => false, 'placeholder'=> __('auth.email')]) !!}
{!! FormField::password('password', ['label' => false, 'placeholder'=> __('auth.password')]) !!}
{!! FormField::checkboxes('remember', [__('auth.remember_me')]) !!}
{{ Form::submit(__('auth.login'), ['class' => 'btn btn-success btn-block']) }}
{{ link_to_route('auth.reset-request', __('auth.forgot_password'), [], ['class' => 'btn btn-link']) }}
{{ Form::close() }}

Loading…
Cancel
Save