doubi7346 2018-05-22 14:54
浏览 185

Laravel创建并授权登录

I have a simple registration where validation passes, but create doesn't fill up fullname and phone(I checked they are passed - by echoing). I also tried by using request()->input('fullname'); but I got same result.

For login after storing values this auth()->login($user) and auth()->attempt() both fails.

I don't know since uniqid for password is same as stored....

public function register(Request $request) {
        $this->validate($request, [
            'fullname' => 'required|min:2|max:255',
            'email' => 'required|email|unique:users',
            'phone' => 'required'
        ]);

        $passcode = uniqid();

        $user = User::create([
            'fullname' => $request->fullname,
            'email' => $request->email,
            'password' => bcrypt($passcode),
            'phone' => $request->phone
        ]);

        if(User::sendEmail($passcode, $request->email,  $request->fullname)) {
            if (auth()->login($user)) {
                session()->flash('user', 'You have been logged in..');
                session()->flash('data', request());
                return redirect()->route('dashboard');
            }
        session()->flash('login', 'Not logged in.');
        }
        return redirect()->back();

    }

<form action="{{ route('register') }}" method="POST">
    {{ csrf_field() }}
    <input type="text" name="fullname" placeholder="Full name">
    <input type="text" name="email" placeholder="E-mail">
    <input type="text" name="phone" placeholder="Phone">
    <button type="submit">Continue</button>
</form>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法