I make an angular/strapi(4.15.00) project, where i can register users. I enabled in the strapi admin to send confirmation email to the new user, and the email should contain a token. <%= TOKEN %> but the token not generated. I make a reset password email too, and that is works fine, i get the token, and i can use it to authenticate. Theoritically strapi generate me a token, like on the reset password method. I am new in strapi.
the frontend angular method:
public register(data: IUserData): Observable<any> {
return this.http.post(API_URL + '/api/auth/local/register', data).pipe(
tap({
next: (res: any) => {
console.log(
'Registration successful, confirmation email sent:',
res
);
localStorage.setItem(JWT_FIELD, res.jwt);
console.log(
'timeLockOrStayLoggedIn:' + data.timeLockOrStayLoggedIn
);
},
error: (error) => {
console.log('An error occurred:', error);
},
})
);
}
On the advanced settings, i enabled the email confirmation.
i check everything on roles => users and permissions=> PUBLIC => email and user permissions i check everything on roles => users and permissions=> AUTHENTICATED => email and user permissions
This is my test email template for email confirmation: (i tried some format, but nothing works)
<p><%= URL %>?confirmation=<%= TOKEN %></p>
<p>http://localhost:4200/login/sign-in?code=<%= TOKEN %></p>
<p>http://localhost:1337/api/auth/email-confirmation?confirmation=<%= TOKEN %></p>
<p>http://localhost:4200/login/sign-in?confirmation=<%= TOKEN %></p>
<p><%= TOKEN %></p>
<p><%= URL%></p>
every link show this message on browser:
"{"data":null,"error":{"status":400,"name":"ValidationError","message":"confirmation is a required field","details":{"errors":[{"path":["confirmation"],"message":"confirmation is a required field","name":"ValidationError"}]}}}"
Does anybody know, how to solve this?:D Thanks!