Last version before the auth-pocalypse

This commit is contained in:
Torsten 2017-08-24 17:45:30 +02:00
parent 70e28110cb
commit 11135e743c
11 changed files with 334 additions and 14 deletions

View file

@ -29,4 +29,15 @@ class ForgotPasswordController extends Controller
{
$this->middleware('guest');
}
/**
* Display the form to request a password reset link.
*
* @return \Illuminate\Http\Response
*/
public function showLinkRequestForm()
{
return view('auth.passwords.email');
}
}

View file

@ -12,6 +12,14 @@ use App\Tipp;
use App\Quota;
use App\Mail\RoundmailMailer;
use Password;
use Illuminate\Contracts\Auth\Guard;
//use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Auth\Passwords\PasswordBroker;
use DB;
use Auth;
use Log;
@ -21,14 +29,11 @@ use Carbon;
class UsersController extends Controller
{
public function main() {
$currentSeason=Season::getCurrent();
$roundname="";
$report="";
$result=User::hasMissingJoker(1);
Log::info("!!! =>".$result);
if (!$result) { Log::info("Joker is missing");}
$currentSeason=Season::getCurrent();
// display_rounds berechnen für Nav und Rundenberichte
$display_rounds=array();
if ($currentSeason) {
$round_id = Round::getLastCompleteRoundId();
@ -47,7 +52,23 @@ class UsersController extends Controller
} else { Log::info("No round identified. Last Locked=".$round_id); $report="";}
} else {Log::info("No current season");}
return view('main',compact('roundname','display_rounds'));
$nextRoundName="";
$nextRoundId = Round::getFirstIncompleteRound();
if ($nextRoundId>-1) { $nextRoundName = Round::where('id','=',$nextRoundId)->first()->name; }
$user=Auth::user();
$message_text_tipps="";
$message_text_joker="";
if ($user && $currentSeason) {
if (User::hasMissingTipp($user->id)) {
$message_text_tipps="Fehlende Tipps für ".$nextRoundName;
}
if (User::hasMissingJoker($user->id)) {
$message_text_joker="Fehlender Joker für ".$nextRoundName;
}
}
return view('main',compact('roundname','display_rounds','message_text_joker','message_text_tipps','nextRoundName'));
}
public function index() {
@ -444,4 +465,28 @@ class UsersController extends Controller
}
public function test() {
//Password::sendResetLink(['email','magus@zauberturm.de']);
$request = new Request();
$request->merge(['email'=>'magus@zauberturm.de']);
$broker = $this->getBroker();
$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
}
// App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail
public function reset() {
return view('auth.passwords.email');
}
public function processReset(Request $request) {
$response = $this->broker()->sendResetLink(
$request->only('email')
);
}
}

View file

@ -3,7 +3,7 @@
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Foundation\Auth\User as Authenticatable; // already implements CanResetPassword
use App\Season;
use App\Payment;
use App\Round;
@ -134,18 +134,12 @@ class User extends Authenticatable
$round_id = Round::getFirstIncompleteRound();
$games = Game::where('round_id','=',$round_id)->get();
foreach ($games as $game) {
$tipp = Tipp::where([['game_id','=',$game->id],['user_id','=',$user_id]])->first();
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
Log::info("!!! User ".$user_id." has a missing tipp for game_id ".$game->id.", round = ".$round_id);
return 1;
} else {
if ($user_id==2) {
}
}
}
return 0;
@ -176,4 +170,5 @@ class User extends Authenticatable
return true;
}
}

View file

@ -56,3 +56,31 @@ footer {
footer p {
margin-bottom: .25rem;
}
.blink_text {
animation:1s blinker linear infinite;
-webkit-animation:1s blinker linear infinite;
-moz-animation:1s blinker linear infinite;
color: red;
}
@-moz-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
@-webkit-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
@keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}

View file

@ -0,0 +1,69 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Login</div>
<div class="panel-body">
<form class="form-horizontal" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Login
</button>
<a class="btn btn-link" href="{{ route('password.request') }}">
Forgot Your Password?
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -0,0 +1 @@
Hallo Welt ! (email.blade.php)

View file

@ -0,0 +1,70 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Reset Password</div>
<div class="panel-body">
<form class="form-horizontal" method="POST" action="{{ route('password.request') }}">
{{ csrf_field() }}
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Reset Password
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -0,0 +1,77 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" method="POST" action="{{ route('register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -0,0 +1 @@
Click here to reset your password: {{ url('password/reset/'.$token) }}

View file

@ -2,6 +2,13 @@
@section('content')
<section class="jumbotron text-center">
@if (strlen($message_text_tipps)>0)
<div><p class="blink_text">{{ $message_text_tipps }}</p></div>
@endif
@if (strlen($message_text_joker)>0)
<div><p class="blink_text">{{ $message_text_joker }}</p></div>
@endif
<div class="container">
<h1 class="jumbotron-heading">Hoschis Tippspiel</h1>
<p class="lead text-muted">Eine Tippgemeinschaft unter Freunden.</p>

View file

@ -54,3 +54,19 @@ Route::get('/email','UsersController@mailtest');
Route::get('/roundmails','RoundmailController@index');
Route::get('/roundmails/show/{mail_id}','RoundmailController@show');
Route::post('/roundmails/send','RoundmailController@send');
Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm');
Route::get('test','UsersController@test');
/*
Route::get('/reset','UsersController@reset')->name('password.email');
Route::post('/reset','UsersController@processReset')->name('password.request');
*/
Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('/abc','Auth\ForgotPasswordController@abc');
//Route::auth();