1
0
mirror of https://github.com/fazo96/homework.git synced 2025-01-09 12:10:08 +01:00

better email verification system

This commit is contained in:
fazo96 2014-05-30 11:40:15 +02:00
parent ce8442a6ab
commit c5090f25e3
3 changed files with 15 additions and 6 deletions

View File

@ -35,10 +35,19 @@ Router.map ->
if amIValid() is no then Router.go 'verifyEmail'
if not @data() then Router.go 'notes'
@route 'verifyEmail',
path: '/verify/:token?'
template: 'verifyEmail'
onBeforeAction: ->
if not getUser() then Router.go 'home'
if amIValid() is yes then Router.go 'notes'
if @params.token?
Accounts.verifyEmail @params.token, (err) ->
if err
Router.go 'home'
errCallback err
else Router.go 'notes'
else if not getUser()
Router.go 'home'
else if amIValid() is yes then Router.go 'notes'
# Client Templates

View File

@ -76,7 +76,7 @@
<template name="verifyEmail">
<div align="center">
<p>Insert the token you received by email at the address {{mail}} here:</p>
<p>Insert the token you received by email at the address {{email}} here, or click the link in the email we sent you.</p>
<input type="text" id="token-field" class="form-control" placeholder="Token">
<div align="center" class="buttons">
<button type="button" class="btn btn-warning btn-ver" id="btn-resend">Resend Email</button>

View File

@ -21,9 +21,9 @@ Accounts.config {
Accounts.emailTemplates.siteName = "Homework App";
Accounts.emailTemplates.verifyEmail.text = (user,url) ->
token = url.split('/'); token = token[token.length-1]
'''Welcome to Homework! To activate your account, log in then provide the \
following token: '''+token
urlist = url.split('/'); token = urlist[urlist.length-1]
'''Welcome to Homework! To activate your account, click on the \
following link: http://homework.meteor.com/verify/'''+token
# Returns true if the user has verified at least one email address
userValidated = (user) ->