mirror of
https://github.com/fazo96/homework.git
synced 2025-01-10 12:14:22 +01:00
new file organization
This commit is contained in:
parent
fdbfdb66ac
commit
2d92401442
@ -1,18 +1,19 @@
|
|||||||
# Homework - Client Side
|
# Homework - Client Side
|
||||||
notes = new Meteor.Collection "notes"
|
notes = new Meteor.Collection "notes"
|
||||||
Deps.autorun -> Meteor.subscribe "my-notes" unless not Meteor.userId()
|
Deps.autorun -> Meteor.subscribe "my-notes" unless not Meteor.userId()
|
||||||
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
|
|
||||||
getUser = -> Meteor.user()
|
getUser = -> Meteor.user()
|
||||||
amIValid = ->
|
amIValid = ->
|
||||||
return no unless getUser()
|
return no unless getUser()
|
||||||
return yes for mail in getUser().emails when mail.verified is yes; no
|
return yes for mail in getUser().emails when mail.verified is yes; no
|
||||||
# Helpers
|
|
||||||
|
# Common Helpers
|
||||||
UI.registerHelper "loggingIn", -> Meteor.loggingIn()
|
UI.registerHelper "loggingIn", -> Meteor.loggingIn()
|
||||||
UI.registerHelper "mail", -> getUser().emails[0].address
|
UI.registerHelper "mail", -> getUser().emails[0].address
|
||||||
UI.registerHelper "verified", -> amIValid()
|
UI.registerHelper "verified", -> amIValid()
|
||||||
|
|
||||||
|
# Client Templates
|
||||||
|
|
||||||
# User Interface
|
# User Interface
|
||||||
Template.userInfo.events
|
Template.userInfo.events
|
||||||
'click #logout': (e,template) -> Meteor.logout()
|
'click #logout': (e,template) -> Meteor.logout()
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# Homework - Server Side
|
# Homework - Server Side
|
||||||
console.log "Started Homework server!"
|
console.log "Started Homework server!"
|
||||||
console.log "Sending emails using "+process.env.MAIL_URL
|
if process.env.MAIL_URL
|
||||||
|
console.log "Sending emails using "+process.env.MAIL_URL
|
||||||
|
else
|
||||||
|
console.log "Not Sending Emails, please set the MAIL_URL environment variable"
|
||||||
|
|
||||||
notes = new Meteor.Collection "notes"
|
notes = new Meteor.Collection "notes"
|
||||||
|
|
||||||
@ -23,9 +26,11 @@ Accounts.emailTemplates.verifyEmail.text = (user,url) ->
|
|||||||
# Returns true if the user has verified at least one email address
|
# Returns true if the user has verified at least one email address
|
||||||
userValidated = (user) ->
|
userValidated = (user) ->
|
||||||
if not user?
|
if not user?
|
||||||
throw new Meteor.Exception "Impossible! Trying to validate null user"
|
console.log "Impossible! Trying to validate null user"
|
||||||
|
return no
|
||||||
return yes for mail in user.emails when mail.verified is yes; no
|
return yes for mail in user.emails when mail.verified is yes; no
|
||||||
|
|
||||||
|
# Publish user's notes to each user.
|
||||||
Meteor.publish "my-notes", ->
|
Meteor.publish "my-notes", ->
|
||||||
if userValidated getUser(@userId)
|
if userValidated getUser(@userId)
|
||||||
notes.find userId: @userId
|
notes.find userId: @userId
|
||||||
@ -39,10 +44,6 @@ Accounts.validateNewUser (user) ->
|
|||||||
|
|
||||||
# Methods that the clients can invoke
|
# Methods that the clients can invoke
|
||||||
Meteor.methods
|
Meteor.methods
|
||||||
amIValidated: ->
|
|
||||||
u = getUser(@userId)
|
|
||||||
return no unless u?
|
|
||||||
userValidated u
|
|
||||||
resendConfirmEmail: ->
|
resendConfirmEmail: ->
|
||||||
u = getUser(@userId)
|
u = getUser(@userId)
|
||||||
if not u
|
if not u
|
||||||
|
5
shared/utils.coffee
Normal file
5
shared/utils.coffee
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Utility functions for client and server - Homework
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user