I am designing a program which the person (be user, admin, client, etc), register and this I sent an email with the authentication route and thus ends the registration process.
the person enters the page and places his email and password.
the app generates an access token and saves the email as identity, takes the email and sends the token with a link.
when clicking on the link redirects to the page, the app searches for the access token and thus allow the user to finish their registration process (name, surname, address, telephone, etc).
I am using python together with the flask framework. so far I have to do the access token and the authentication required to access the different routes. my problem is to send the link with the token to the person's email.
for sending mail I am using the SMTPLIB and this is the code
user = 'xxxxxxxxxx@gmail.com'
password = 'xxxxxxxxx'
remitente = 'xxxxxxxxxx@gmail.com'
destinatario = destinatario
asunto = 'Registro Exitoso'
mensaje = 'ok: <a href="nuevoenlace">nuevoenlace</a>'
gmail = smtplib.SMTP('smtp.gmail.com', 587)
gmail.starttls()
gmail.login(user, password)
header = MIMEMultipart()
header['From'] = remitente
header['To'] = destinatario
header['Subject'] = asunto
mensaje = MIMEText(mensaje, 'html')
header.attach(mensaje)
gmail.sendmail(remitente, destinatario, header.as_string())
gmail.quit()
ok, my problem is to send the token by mail along with authentication link, this redirects me to a protected endpoint and finishes the entry process