2014-05-31 18:09:56 +02:00
|
|
|
# Homework - Server side accounts code
|
|
|
|
|
2014-06-05 17:03:10 +02:00
|
|
|
# Regular Expression to see if an email can be valid
|
2014-05-31 18:09:56 +02:00
|
|
|
validateEmail = (email) ->
|
|
|
|
x = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
|
|
|
|
x.test email
|
|
|
|
|
2014-06-05 17:03:10 +02:00
|
|
|
Accounts.config {
|
|
|
|
sendVerificationEmail: true
|
|
|
|
loginExpirationInDays: 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Code that checks if a new user request is valid
|
2014-05-31 18:09:56 +02:00
|
|
|
Accounts.validateNewUser (user) ->
|
|
|
|
mail = user.emails[0].address
|
|
|
|
if Match.test(mail,String) is no or validateEmail(mail) is no
|
|
|
|
throw new Meteor.Error 403, "Invalid Email"
|
|
|
|
return yes
|
|
|
|
|
2014-06-05 17:03:10 +02:00
|
|
|
# Email configuration code
|
2014-05-31 18:09:56 +02:00
|
|
|
Accounts.emailTemplates.siteName = "Homework App"
|
|
|
|
Accounts.emailTemplates.verifyEmail.text = (user,url) ->
|
|
|
|
urlist = url.split('/'); token = urlist[urlist.length-1]
|
2014-10-04 09:14:28 +02:00
|
|
|
url = Meteor.absoluteUrl 'verify/'+token
|
2014-05-31 18:09:56 +02:00
|
|
|
'''Welcome to Homework! To activate your account, click on the \
|
2014-10-04 09:14:28 +02:00
|
|
|
following link: '''+url
|