2014-05-27 15:33:50 +02:00
|
|
|
# Homework - Server Side
|
|
|
|
notes = new Meteor.Collection "notes"
|
|
|
|
|
2014-05-27 16:02:37 +02:00
|
|
|
validateEmail = (email) ->
|
|
|
|
expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
|
|
|
|
expr.test email
|
|
|
|
|
2014-05-27 15:33:50 +02:00
|
|
|
Accounts.config {
|
2014-05-27 15:34:25 +02:00
|
|
|
sendVerificationEmail: false
|
2014-05-27 15:33:50 +02:00
|
|
|
loginExpirationInDays: 1
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish "my-notes", ->
|
|
|
|
notes.find( { userId: @userId } ) unless not @userId
|
|
|
|
|
|
|
|
# Authentication
|
|
|
|
Accounts.validateNewUser (user) ->
|
2014-05-27 16:02:37 +02:00
|
|
|
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
|