使用Laravel5.1框架怎么实现一个登录和注册功能

  介绍

本篇文章给大家分享的是有关使用Laravel5.1框架怎么实现一个登录和注册功能,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

1配置

我们可以在config/身份验证。php文件中进行用户认证的配置:

& lt; php ?   return  [   ,/*   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   |才能,Default  Authentication 司机   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   ,|   |才能,却;能够option  controls 从而authentication  driver  that  will  be 利用。   |才能,却;能够driver  manages 从而retrieval 以及authentication  of 从而用户   |才能,attempting 用get  access 用protected  areas  of  your 应用程序。   ,|   |才能,支持:,“database",,“eloquent"   ,|   ,*/& # 39;才能司机# 39;,=祝辞,& # 39;雄辩的# 39;   ,/*   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   |才能,Authentication 模型   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   ,|   |才能,When  using ,“Eloquent", authentication 司机,need 用知道我方表示歉意   |才能,Eloquent  model  should  be  used 用retrieve  your 用户只Of 当然,它   |才能,is  often  just ,“User", model  but 你may  use  whatever 你喜欢。   ,|   ,*/& # 39;才能模型# 39;,=祝辞,App \用户::类,   ,/*   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   |才能,Authentication 表   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   ,|   |才能,When  using ,“Database", authentication 司机,need 用知道我方表示歉意   |才能,table  should  be  used 用retrieve  your 用户只have  chosen  a 基本我方表示歉意   |才能,default  value  but 你may  easily  change  it 用any  table 你喜欢。   ,|   ,*/& # 39;才能表# 39;,=祝辞,& # 39;用户# 39;   ,/*   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   |才能,Password  Reset 设置   |才能- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   ,|   |才能,Here 你may  set 从而options  for  resetting  passwords  including 从而视图   |才能,that  is  your  password  reset 电子邮件又是;你还要also  set 从而name  of    |才能,table  that  maintains  all  of 从而reset  tokens  for  your 应用程序。   ,|   |才能,从而expire  time  is 从而number  of  minutes  that 从而reset  token  should    |才能,considered 有效只却;能够security  feature  keeps  tokens  short-lived 所以   |才能,活动对象;have  less  time 用be 猜只你may  change 却;能够as 需要。   ,|   ,*/& # 39;才能密码# 39;,=祝辞,(   ,,,& # 39;电子邮件,,=祝辞,& # 39;emails.password& # 39;   ,,,& # 39;表# 39;,=祝辞,& # 39;password_resets& # 39;   ,,,& # 39;到期# 39;,=祝辞,60岁,   ,,,   ];

这是默认的配置,注释写的很清楚了如果有特别需要可以做更改,一般情况中我们使用默认的就好。

2创建路由

/* *   ,*用户认证   ,*///,getLogin 用于展示登录表单。   路线:get(& # 39;/身份验证/登录# 39;,,& # 39;auth \ AuthController@getLogin& # 39;);//,postLogin 用于提交用户登录数据。   路线::post(& # 39;/身份验证/登录# 39;,,& # 39;auth \ AuthController@postLogin& # 39;);//,getLogout 用于退出登录。   路线:get(& # 39;/认证/注销# 39;,,& # 39;auth \ AuthController@getLogout& # 39;);/* *   ,*用户注册   ,*///,getRegister 用于展示注册表单。   路线:get(& # 39;/认证/注册# 39;,,& # 39;auth \ AuthController@getRegister& # 39;);//,postRegister 用于提交用户注册数据。   路线::post(& # 39;/认证/注册# 39;,,& # 39;auth \ AuthController@postRegister& # 39;);

使用Laravel5.1框架怎么实现一个登录和注册功能