Working on users in L5

This commit is contained in:
Hillel Coren 2015-03-30 18:20:53 +03:00
parent 78502f74e4
commit 58746d9eec
8 changed files with 76 additions and 134 deletions

View File

@ -20,6 +20,8 @@ class PasswordController extends Controller {
use ResetsPasswords; use ResetsPasswords;
protected $redirectTo = '/dashboard';
/** /**
* Create a new password controller instance. * Create a new password controller instance.
* *

View File

@ -66,8 +66,10 @@ post('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@postRegis
get('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@getLogin')); get('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@getLogin'));
post('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@postLogin')); post('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@postLogin'));
get('/logout', array('as' => 'logout', 'uses' => 'Auth\AuthController@getLogout')); get('/logout', array('as' => 'logout', 'uses' => 'Auth\AuthController@getLogout'));
get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\AuthController@getLogin')); get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail'));
post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\AuthController@postLogin')); post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail'));
get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset'));
post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset'));
/* /*
// Confide routes // Confide routes

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function(Blueprint $table)
{
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('password_resets');
}
}

View File

@ -65,10 +65,10 @@
{!! Former::password('password')->placeholder(trans('texts.password'))->raw() !!} {!! Former::password('password')->placeholder(trans('texts.password'))->raw() !!}
</p> </p>
<p>{!! Button::primary(trans('texts.lets_go'))->withAttributes(array('class' => 'btn-lg'))->submit()->block() !!}</p> <p>{!! Button::success(trans('texts.lets_go'))->withAttributes(array('class' => 'btn-lg'))->submit()->block() !!}</p>
<p class="link"> <p class="link">
{!! link_to('forgot_password', trans('texts.forgot_password')) !!} {!! link_to('/forgot', trans('texts.forgot_password')) !!}
</p> </p>

View File

@ -53,7 +53,7 @@
@section('body') @section('body')
<div class="container"> <div class="container">
{!! Former::open('forgot_password')->rules(['email' => 'required|email'])->addClass('form-signin') !!} {!! Former::open('forgot')->rules(['email' => 'required|email'])->addClass('form-signin') !!}
<div class="modal-header"> <div class="modal-header">
<img src="{{ asset('images/icon-login.png') }}" /> <img src="{{ asset('images/icon-login.png') }}" />
<h4>Invoice Ninja | {{ trans('texts.password_recovery') }}</h4></div> <h4>Invoice Ninja | {{ trans('texts.password_recovery') }}</h4></div>
@ -63,7 +63,21 @@
{!! Former::text('email')->placeholder(trans('texts.email_address'))->raw() !!} {!! Former::text('email')->placeholder(trans('texts.email_address'))->raw() !!}
</p> </p>
<p>{!! Button::normal(trans('texts.send_email'))->withAttributes(array('class' => 'btn-lg'))->submit()->block() !!}</p> <p>{!! Button::success(trans('texts.send_email'))->withAttributes(array('class' => 'btn-lg'))->submit()->block() !!}</p>
@if (count($errors->all()))
<div class="alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</div>
@endif
@if (session('status'))
<div class="alert alert-info">
{{ session('status') }}
</div>
@endif
<!-- if there are login errors, show them here --> <!-- if there are login errors, show them here -->
@if (Session::has('warning')) @if (Session::has('warning'))

View File

@ -53,10 +53,10 @@
@section('body') @section('body')
<div class="container"> <div class="container">
{{ Former::open('user/reset')->addClass('form-signin')->rules(array( {!! Former::open('/password/reset')->addClass('form-signin')->rules(array(
'password' => 'required', 'password' => 'required',
'password_confirmation' => 'required', 'password_confirmation' => 'required',
)); }} )) !!}
<div class="modal-header"> <div class="modal-header">
<img src="{{ asset('images/icon-login.png') }}" /> <img src="{{ asset('images/icon-login.png') }}" />
@ -66,12 +66,22 @@
<input type="hidden" name="token" value="{{{ $token }}}"> <input type="hidden" name="token" value="{{{ $token }}}">
<p> <p>
{{ Former::password('password')->placeholder(trans('texts.password'))->raw() }} {!! Former::text('email')->placeholder(trans('texts.email'))->raw() !!}
{{ Former::password('password_confirmation')->placeholder(trans('texts.confirm_password'))->raw() }} {!! Former::password('password')->placeholder(trans('texts.password'))->raw() !!}
{!! Former::password('password_confirmation')->placeholder(trans('texts.confirm_password'))->raw() !!}
</p> </p>
<p>{{ Button::success_submit(trans('texts.save'), array('class' => 'btn-lg'))->block() }}</p> <p>{!! Button::success(trans('texts.save'), array('class' => 'btn-lg'))->submit()->block() !!}</p>
@if (count($errors->all()))
<div class="alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</div>
@endif
<!-- if there are login errors, show them here --> <!-- if there are login errors, show them here -->
@if (Session::has('warning')) @if (Session::has('warning'))
@ -87,7 +97,7 @@
@endif @endif
{{ Former::close() }} {!! Former::close() !!}
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
{{ trans('texts.email_salutation', ['name' => $user->username]) }} <p/> {{ trans('texts.email_salutation', ['name' => $user->username]) }} <p/>
{{ trans('texts.reset_password') }} <br/> {{ trans('texts.reset_password') }} <br/>
{{{ (Confide::checkAction('UserController@reset_password', array($token))) ? : URL::to('user/reset/'.$token) }}}<p/> {!! url('password/reset/'.$token) !!}<p/>
{{ trans('texts.email_signature') }} <br/> {{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/> {{ trans('texts.email_from') }} <p/>

View File

@ -1,119 +0,0 @@
@extends('master')
@section('head')
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css"/>
<link href="{{ asset('css/style.css') }}" rel="stylesheet" type="text/css"/>
<style type="text/css">
body {
padding-top: 40px;
padding-bottom: 40px;
}
.modal-header {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.modal-header h4 {
margin:0;
}
.modal-header img {
float: left;
margin-right: 20px;
}
.form-signin {
max-width: 400px;
margin: 0 auto;
background: #fff;
}
p.link a {
font-size: 11px;
}
.form-signin .inner {
padding: 20px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
margin-bottom: 17px !important;
}
.form-signin .form-control:focus {
z-index: 2;
}
</style>
@endsection
@section('body')
<div class="container">
{!! Former::open('login')->rules(['login_email' => 'required|email', 'login_password' => 'required'])->addClass('form-signin') !!}
<div class="modal-header">
<img src="{{ asset('images/icon-login.png') }}" />
<h4>Invoice Ninja | {{ trans('texts.account_login') }}</h4></div>
<div class="inner">
<p>
{{ $errors->first('login_email') }}
{{ $errors->first('login_password') }}
</p>
<p>
{!! Former::text('login_email')->placeholder(trans('texts.email_address'))->raw() !!}
{!! Former::password('login_password')->placeholder(trans('texts.password'))->raw() !!}
</p>
<p>{!! Button::primary(trans('texts.lets_go'))->withAttributes(array('class' => 'btn-lg'))->submit()->block() !!}</p>
<p class="link">
{!! link_to('forgot_password', trans('texts.forgot_password')) !!}
</p>
@if (Session::has('warning'))
<div class="alert alert-warning">{{ Session::get('warning') }}</div>
@endif
@if (Session::has('message'))
<div class="alert alert-info">{{ Session::get('message') }}</div>
@endif
@if (Session::has('error'))
<div class="alert alert-danger">{{ Session::get('error') }}</div>
@endif
</div>
{!! Former::close() !!}
@if (!Utils::isNinja())
<p/>
<center>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=635126583203143";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-follow" data-href="https://www.facebook.com/invoiceninja" data-colorscheme="light" data-layout="button" data-show-faces="false"></div>&nbsp;&nbsp;
<a href="https://twitter.com/invoiceninja" class="twitter-follow-button" data-show-count="false" data-related="hillelcoren" data-size="medium">Follow @invoiceninja</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<iframe src="https://ghbtns.com/github-btn.html?user=hillelcoren&repo=invoice-ninja&type=star&count=false" frameborder="0" scrolling="0" width="50px" height="20px"></iframe>
</center>
@endif
</div>
@endsection