dsz7121 2018-02-07 11:49
浏览 108
已采纳

允许注册用户注册新用户并在注册后禁用自动登录

I have created an admin panel for my application. Also implemented auth system. But laravel's standard auth system doesn't allow registered users create new ones and always redirect to /home route. I have overrided the register(Request $request) method in order to disable auto-login, but I still have a trouble with the registration. How can I implement such a functionality? What's the workaround?

Here's the overrided register(Request $request) method in RegisterController:

public function register(Request $request)
{
    $this->validator($request->all())->validate();

    event(new Registered($user = $this->create($request->all())));

    return redirect()->route('users');
}
  • 写回答

2条回答 默认 最新

  • douzhaxian1267 2018-02-07 11:52
    关注

    You can manually create a user:

    Just create a new form and pass the required fields and then in your controller use them to create a new user.

    $user = new App\User();
    $user->password = Hash::make('the-password-of-choice');
    $user->email = 'the-email@example.com';
    $user->save();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图