-
Notifications
You must be signed in to change notification settings - Fork 189
/
signIn.coffee
45 lines (37 loc) · 1.31 KB
/
signIn.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Template.entrySignIn.helpers
emailInputType: ->
if AccountsEntry.settings.passwordSignupFields is 'EMAIL_ONLY'
'email'
else
'string'
emailPlaceholder: ->
fields = AccountsEntry.settings.passwordSignupFields
if _.contains([
'USERNAME_AND_EMAIL'
'USERNAME_AND_OPTIONAL_EMAIL'
], fields)
return i18n("usernameOrEmail")
else if fields == "USERNAME_ONLY"
return i18n("username")
return i18n("email")
logo: ->
AccountsEntry.settings.logo
Template.entrySignIn.events
'submit #signIn': (event) ->
event.preventDefault()
email = $('input[name="email"]').val()
if (AccountsEntry.isStringEmail(email) and AccountsEntry.settings.emailInsensitive) or
(not AccountsEntry.isStringEmail(email) and AccountsEntry.settings.usernameInsensitive)
email = email.toLowerCase()
Session.set('email', email)
Session.set('password', $('input[name="password"]').val())
Meteor.loginWithPassword(Session.get('email'), Session.get('password'), (error)->
Session.set('password', undefined)
if error
T9NHelper.accountsError error
else if Session.get('fromWhere')
Router.go Session.get('fromWhere')
Session.set('fromWhere', undefined)
else
Router.go AccountsEntry.settings.dashboardRoute
)