php - Creating user in Laravel 5 -
so following angular/laravel 5 tutorial using json web tokens. running issue.
here how says create user:
route::post('/signup', function () { $credentials = input::only('email', 'password','name'); try { $user = user::create($credentials); } catch (exception $e) { return response::json(['error' => 'user exists.'], illuminate\http\response::http_conflict); } $token = jwtauth::fromuser($user); return response::json(compact('token')); });
the problem is, user::create($credentials);
not encrypt password, meaning, logins fail. found out using laravel's default registration.
my question is, how create new user creates correct way?
you have hash password using hash
helper class. try this:
route::post('/signup', function () { $credentials = input::only('email', 'password','name'); $credentials['password'] = hash::make($credentials['password']); try { $user = user::create($credentials); } catch (exception $e) { return response::json(['error' => 'user exists.'], illuminate\http\response::http_conflict); } $token = jwtauth::fromuser($user); return response::json(compact('token')); });
ReplyDeleteParasoft’s suite of automated software testing tools integrates quality into the software delivery process for early prevention, detection, and remediation of defects. Parasoft continuous quality suite covers static code analysis, unit testing and code coverage, API testing and service virtualization, and UI testing, enabling delivery at speed and compliance with industry and security standards.