I am pretty new to Angular 4 and have a bit of experience with Laravel 5,Im trying to send email to new user so that they can verify their email address but Im receiving an exception
"message": "Expected response code 250 but got code \"530\", with message \"530-5.5.1 Authentication Required
Authentication required
And this is My Register function
public function signup(Request $request){
$this-> validate($request,[
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6',
]);
$user = new User([
'name' => $request-> input('name'),
'email' => $request-> input('email'),
'password' => bcrypt( $request-> input('password'))
]);
$user -> save();
$verifyUser = VerifyUser::create([
'user_id' => $user->id,
'token' => str_random(40)
]);
$mailer = app()['mailer'];
$mailer->to($user->email)->send(new VerifyMail($user));
return $user;
return response()-> json(['message'=> 'successfully created user'] ,201);
}
public function signin(Request $request){
$this->validate($request,[
'email' => 'required|email',
'password' => 'required'
]);
$credentials = $request->only('email','password');
try{
if (!$token =JWTAuth::attempt($credentials)){
return response()->json(['error'=> 'Invalid Credentials!'] ,404);
}
}catch(JWTException $e){
return response()->json(['error'=> 'Could not create Token!'] ,500);
}
return response()->json(['token'=> $token] ,200);
}
and in my .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=refkakaramti@gmail.com
MAIL_PASSWORD=root
MAIL_ENCRYPTION=tls
Signup(info){
console.log(info);
var data = JSON.stringify(info);
return this.http.post(this.server +"signup" , data, this.options).map(res => res.json());
}
some one help me what should have I add in my angular 4 to make it work
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire