2016-05-11 17:39:26 -04:00
|
|
|
RootView = require 'views/core/RootView'
|
|
|
|
State = require 'models/State'
|
|
|
|
template = require 'templates/user/email-verified-view'
|
|
|
|
User = require 'models/User'
|
|
|
|
|
|
|
|
module.exports = class EmailVerifiedView extends RootView
|
|
|
|
id: 'email-verified-view'
|
|
|
|
template: template
|
|
|
|
|
2016-05-20 17:52:04 -04:00
|
|
|
events:
|
|
|
|
'click .login-button': 'onClickLoginButton'
|
|
|
|
|
2016-05-11 17:39:26 -04:00
|
|
|
initialize: (options, @userID, @verificationCode) ->
|
|
|
|
super(options)
|
|
|
|
@state = new State(@getInitialState())
|
|
|
|
@user = new User({ _id: @userID })
|
|
|
|
@user.sendVerificationCode(@verificationCode)
|
|
|
|
|
|
|
|
@listenTo @state, 'change', @render
|
|
|
|
@listenTo @user, 'email-verify-success', ->
|
|
|
|
@state.set { verifyStatus: 'success' }
|
2016-05-20 17:52:04 -04:00
|
|
|
me.fetch()
|
2016-05-11 17:39:26 -04:00
|
|
|
@listenTo @user, 'email-verify-error', ->
|
|
|
|
@state.set { verifyStatus: 'error' }
|
|
|
|
|
|
|
|
getInitialState: ->
|
|
|
|
verifyStatus: 'pending'
|
2016-05-20 17:52:04 -04:00
|
|
|
|
|
|
|
onClickLoginButton: (e) ->
|
|
|
|
AuthModal = require 'views/core/AuthModal'
|
|
|
|
@openModalView(new AuthModal())
|