Daniel Müllers 11 年之前
父节点
当前提交
7bc24be788
共有 6 个文件被更改,包括 122 次插入18 次删除
  1. 2 2
      app/config/mail.php
  2. 32 1
      app/routes.php
  3. 1 13
      app/views/emails/auth/reminder.blade.php
  4. 2 2
      app/views/login.blade.php
  5. 42 0
      app/views/pwform.blade.php
  6. 43 0
      app/views/pwreset.blade.php

+ 2 - 2
app/config/mail.php

@@ -15,7 +15,7 @@ return array(
 	|
 	*/
 
-	'driver' => 'smtp',
+	'driver' => 'sendmail',
 
 	/*
 	|--------------------------------------------------------------------------
@@ -54,7 +54,7 @@ return array(
 	|
 	*/
 
-	'from' => array('address' => null, 'name' => null),
+	'from' => array('address' => 'dumbo-noreply@ascarion.org', 'name' => 'Dumbo Mailsystem'),
 
 	/*
 	|--------------------------------------------------------------------------

+ 32 - 1
app/routes.php

@@ -363,4 +363,35 @@ Route::post('news', array('before' => 'auth', function() {
 		$n->save();
 		return Redirect::to('/')->with('message', 'News erstellt!');
 	}
-}));
+}));
+
+Route::get('passwort-vergessen', function() {
+	return View::make('pwform');
+});
+
+Route::post('passwort-vergessen', function() {
+	$credentials = array('email' => Input::get('email'));
+	return Password::remind($credentials, function($message, $user) {
+		$message->subject('Passwort für Dumbo zurücksetzen.');
+	});
+});
+
+Route::get('passwort-reset/{token}', function($token) {
+	return View::make('pwreset')->with('token', $token);
+});
+
+Route::post('passwort-reset', function() {
+    $credentials = array(
+        'email' => Input::get('email'),
+        'password' => Input::get('password'),
+        'password_confirmation' => Input::get('password_confirmation')
+    );
+
+    return Password::reset($credentials, function($user, $password) {
+        $user->password = Hash::make($password);
+
+        $user->save();
+
+        return Redirect::to('/');
+    });
+});

+ 1 - 13
app/views/emails/auth/reminder.blade.php

@@ -1,13 +1 @@
-<!DOCTYPE html>
-<html lang="en-US">
-	<head>
-		<meta charset="utf-8">
-	</head>
-	<body>
-		<h2>Password Reset</h2>
-
-		<div>
-			To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.
-		</div>
-	</body>
-</html>
+Setze Dein Passwort hier zurück: <a href="{{ URL::to('passwort-reset', array($token)) }}">{{ URL::to('passwort-reset', array($token)) }}</a>

+ 2 - 2
app/views/login.blade.php

@@ -25,10 +25,10 @@
 					@endif
 					<div class="form-group">
 						<button type="submit" class="btn btn-primary">Anmelden</button>
-						<p class="help-block"><a href="#">Passwort vergessen?</a> (Das funktioniert noch nicht)<br>
+						<p class="help-block"><a href="{{ url('passwort-vergessen') }}">Passwort vergessen?</a><br>
 						<a href="{{ url('register') }}">Registrieren</a></p>
 					</div>
-				{{ Form::close()}}
+				{{ Form::close() }}
 				</div>
 			</div>
 		</div>

+ 42 - 0
app/views/pwform.blade.php

@@ -0,0 +1,42 @@
+@extends('hello')
+
+@section('content')
+
+@if (Session::has('error'))
+    {{ trans(Session::get('reason')) }}
+@elseif (Session::has('success'))
+    An e-mail with the password reset has been sent.
+@endif
+
+<div class="container" style="margin-top: 40px;">
+	<div class="row">
+		<div class="col-md-8 col-md-offset-2">
+			<div class="panel panel-default">
+				<div class="panel-heading"><h2 class="panel-title">Passwort zurücksetzen</h2></div>
+				<div class="panel-body">
+					
+				{{ Form::open(array('url' => 'passwort-vergessen')) }}
+					<div class="input-group form-group">
+						<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
+						<input type="email" class="form-control " name="email" placeholder="Email">
+					</div>
+					@if(Session::has('login_errors'))
+						<div class="alert alert-danger alert-dismissable">
+							<button type="button" class="close" data-dismiss="alert">&times;</button>
+							Login-Daten fehlerhaft!
+						</div>
+					@endif
+					<div class="form-group">
+						<button type="submit" class="btn btn-primary">Passwort zurücksetzen</button>
+					</div>
+				{{ Form::close() }}
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+@stop
+
+@section('title')
+Passwort zurücksetzen ~
+@stop

+ 43 - 0
app/views/pwreset.blade.php

@@ -0,0 +1,43 @@
+@extends('hello')
+
+@section('content')
+
+@if (Session::has('error'))
+    {{ trans(Session::get('reason')) }}
+@endif
+
+<div class="container" style="margin-top: 40px;">
+	<div class="row">
+		<div class="col-md-8 col-md-offset-2">
+			<div class="panel panel-default">
+				<div class="panel-heading"><h2 class="panel-title">Passwort zurücksetzen</h2></div>
+				<div class="panel-body">
+					
+				{{ Form::open(array('url' => 'passwort-reset')) }}
+					<input type="hidden" name="token" value="{{ $token }}">
+					<div class="input-group form-group">
+						<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
+						<input type="email" class="form-control " name="email" placeholder="Email">
+					</div>
+					<div class="input-group form-group">
+						<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
+						<input type="password" class="form-control " name="password" placeholder="Passwort">
+					</div>
+					<div class="input-group form-group">
+						<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
+						<input type="password" class="form-control " name="password_confirmation" placeholder="Passwort wiederholen">
+					</div>
+					<div class="form-group">
+						<button type="submit" class="btn btn-primary">Passwort zurücksetzen</button>
+					</div>
+				{{ Form::close() }}
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+@stop
+
+@section('title')
+Passwort zurücksetzen ~
+@stop