Skip to content

Commit

Permalink
Correction login problems + changed auth views
Browse files Browse the repository at this point in the history
  • Loading branch information
ankheur committed Sep 27, 2020
1 parent 660c340 commit fdaea3a
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 117 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function create(array $data)
'username' => $data['username'],
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'password' => $data['password'],
]);
}
}
4 changes: 1 addition & 3 deletions app/Http/Controllers/ProfilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public function edit()

public function update()
{

// dd(request());
$user = current_user();

$attributes = request()->validate([
Expand All @@ -45,7 +43,7 @@ public function update()

if ( !empty(request('password')) ){
$attributes['password'] = request()->validate([
'password' => ['string', 'min:5', 'max:255', 'confirmed']
'password' => ['string', 'min:8', 'max:255', 'confirmed']
])['password'];
}

Expand Down
8 changes: 5 additions & 3 deletions app/helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

function current_user()
{
return auth()->user();
if (!function_exists('current_user')) {
function current_user()
{
return auth()->user();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"license": "MIT",
"require": {
"php": "^7.3",
"php": "^7.4",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
Expand Down
13 changes: 8 additions & 5 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
>
@csrf

@error('login_error')
<p class="text-red-500 text-xs mb-2"><strong>{{ $message }}</strong></p>
@enderror

<div class="mb-6">
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="email"
>
Email
{{ __('Email') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -34,14 +38,13 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="password"
>
Password
{{ __('Password') }}
</label>

<input class="border border-gray-400 p-2 w-full"
type="password"
name="password"
id="password"
autocomplete="current-password"
>

@error('password')
Expand All @@ -61,7 +64,7 @@
<label class="text-xs text-gray-700 font-bold uppercase"
for="remember"
>
Remember Me
{{ __('Remember Me') }}
</label>
</div>

Expand All @@ -75,7 +78,7 @@
<button type="submit"
class="bg-blue-400 text-white rounded py-2 px-4 hover:bg-blue-500 mr-2"
>
Submit
{{ __('Submit') }}
</button>

<a href="{{ route('password.request') }}" class="text-xs text-gray-700">Forgot Your Password?</a>
Expand Down
6 changes: 2 additions & 4 deletions resources/views/auth/passwords/confirm.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@extends('layouts.app')

@section('content')
<x-master>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
Expand Down Expand Up @@ -46,4 +44,4 @@
</div>
</div>
</div>
@endsection
</x-master>
80 changes: 41 additions & 39 deletions resources/views/auth/passwords/email.blade.php
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
@extends('layouts.app')
<x-master>
<div class="container mx-auto flex justify-center">
<x-panel>
<x-slot name="heading">{{ __('Reset Password') }}</x-slot>

@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>

<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif

@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif

<form method="POST" action="{{ route('password.email') }}">
@csrf
<form method="POST" action="{{ route('password.email') }}">
@csrf

<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="mb-6">
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="email"
>
{{ __('E-Mail Address') }}
</label>

<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
<input class="border border-gray-400 p-2 w-full @error('email') is-invalid @enderror"
type="email"
name="email"
id="email"
value="{{ old('email') }}"
autocomplete="email"
required
autofocus
>

@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
@error('email')
<p class="text-red-500 text-xs mt-2">{{ $message }}</p>
@enderror
</div>


<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Send Password Reset Link') }}
</button>
</div>
</div>
</form>
<div class="mb-4">
<button type="submit"
class="bg-blue-400 text-white rounded py-2 px-4 hover:bg-blue-500"
>
{{ __('Send Password Reset Link') }}
</button>
</div>
</div>
</div>
</form>
</x-panel>
</div>
</div>
@endsection
</x-master>
122 changes: 71 additions & 51 deletions resources/views/auth/passwords/reset.blade.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,85 @@
@extends('layouts.app')
<x-master>
<div class="container mx-auto flex justify-center">
<x-panel>
<x-slot name="heading">{{ __('Reset Password') }}</x-slot>

@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<form method="POST" action="{{ route('password.update') }}">
@csrf

<div class="card-body">
<form method="POST" action="{{ route('password.update') }}">
@csrf
<input type="hidden" name="token" value="{{ $token }}">

<input type="hidden" name="token" value="{{ $token }}">
<div class="mb-6">
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="email"
>
{{ __('E-Mail Address') }}
</label>

<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<input class="border border-gray-400 p-2 w-full @error('email') is-invalid @enderror"
type="email"
name="email"
id="email"
autocomplete="email"
value="{{ $email ?? old('email') }}"
required
autofocus
>

@error('email')
<p class="text-red-500 text-xs mt-2">{{ $message }}</p>
@enderror
</div>

<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>

@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="mb-6">
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="password"
>
{{ __('Password') }}
</label>

<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<input class="border border-gray-400 p-2 w-full @error('password') is-invalid @enderror"
type="password"
name="password"
id="password"
autocomplete="new-password"
required
>

<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<p class="text-red-500 text-xs mt-2">{{ $message }}</p>
@enderror
</div>

@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="mb-6">
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="password_confirmation"
>
{{ __('Confirm Password') }}
</label>

<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<input class="border border-gray-400 p-2 w-full"
type="password"
name="password_confirmation"
id="password_confirmation"
autocomplete="new-password"
required
>

@error('password_confirmation')
<p class="text-red-500 text-xs mt-2">{{ $message }}</p>
@enderror
</div>

<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Reset Password') }}
</button>
</div>
</div>
</form>
<div class="mb-4">
<button type="submit"
class="bg-blue-400 text-white rounded py-2 px-4 hover:bg-blue-500"
>
{{ __('Reset Password') }}
</button>
</div>
</div>
</div>
</form>
</x-panel>
</div>
</div>
@endsection
</x-master>
12 changes: 6 additions & 6 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="username"
>
Username
{{ __('Username') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -32,7 +32,7 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="name"
>
Name
{{ __('Name') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -52,7 +52,7 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="email"
>
Email
{{ __('E-Mail Address') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -74,7 +74,7 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="password"
>
Password
{{ __('Password') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -93,7 +93,7 @@
<label class="block mb-2 uppercase font-bold text-xs text-gray-700"
for="password_confirmation"
>
Password Confirmation
{{ __('Confirm Password') }}
</label>

<input class="border border-gray-400 p-2 w-full"
Expand All @@ -112,7 +112,7 @@
<button type="submit"
class="bg-blue-400 text-white rounded py-2 px-4 hover:bg-blue-500"
>
Register
{{ __('Register') }}
</button>
</div>

Expand Down
Loading

0 comments on commit fdaea3a

Please sign in to comment.