diff --git a/app/assets/javascripts/app/controllers/email_verify.coffee b/app/assets/javascripts/app/controllers/email_verify.coffee
index 1f0ad43a2..ae0c5b7d4 100644
--- a/app/assets/javascripts/app/controllers/email_verify.coffee
+++ b/app/assets/javascripts/app/controllers/email_verify.coffee
@@ -1,7 +1,6 @@
class Index extends App.Controller
constructor: ->
super
- @authenticateCheckRedirect()
@verifyCall()
verifyCall: =>
@@ -11,45 +10,23 @@ class Index extends App.Controller
url: "#{@apiPath}/users/email_verify"
data: JSON.stringify(token: @token)
processData: true
- success: @success
- error: @error
- )
+ success: (data, status, xhr) =>
+ App.Auth.loginCheck()
+ @navigate '#'
- success: =>
- new Success(el: @el)
+ @notify
+ type: 'success'
+ msg: App.i18n.translateContent('Woo hoo! Your email address has been verified!')
+ removeAll: true
+ timeout: 2000
- error: =>
- new Fail(el: @el)
+ error: (data, status, xhr) =>
+ @navigate '#'
-class Success extends App.ControllerContent
- constructor: ->
- super
- @render()
-
- # rerender view, e. g. on language change
- @bind 'ui:rerender', =>
- @render()
-
- render: =>
- @renderScreenSuccess(
- detail: 'Woo hoo! Your email address has been verified!'
- )
- delay = =>
- @navigate '#'
- @delay(delay, 20500)
-
-class Fail extends App.ControllerContent
- constructor: ->
- super
- @render()
-
- # rerender view, e. g. on language change
- @bind 'ui:rerender', =>
- @render()
-
- render: =>
- @renderScreenError(
- detail: 'Unable to verify email. Please contact your administrator.'
+ @notify
+ type: 'error'
+ msg: App.i18n.translateContent('Unable to verify email. Please contact your administrator.')
+ removeAll: true
)
App.Config.set('email_verify/:token', Index, 'Routes')
diff --git a/app/assets/javascripts/app/controllers/signup.coffee b/app/assets/javascripts/app/controllers/signup.coffee
index be1ec2cea..ff3374c58 100644
--- a/app/assets/javascripts/app/controllers/signup.coffee
+++ b/app/assets/javascripts/app/controllers/signup.coffee
@@ -2,6 +2,7 @@ class Index extends App.ControllerContent
events:
'submit form': 'submit'
'click .submit': 'submit'
+ 'click .js-submitResend': 'resend'
'click .cancel': 'cancel'
constructor: ->
@@ -61,31 +62,41 @@ class Index extends App.ControllerContent
# save user
user.save(
done: (r) =>
- App.Auth.login(
- data:
- username: @params.login
- password: @params.password
- success: @success
- error: @error
+ @html App.view('signup/verify')(
+ email: @params.email
)
fail: (settings, details) =>
@formEnable(e)
- @form.showAlert(details.error_human || details.error || 'Unable to update object!')
+ if _.isArray(details.error)
+ @form.showAlert( App.i18n.translateInline( details.error[0], details.error[1] ) )
+ else
+ @form.showAlert(details.error_human || details.error || 'Unable to update object!')
)
- success: (data, status, xhr) =>
+ resend: (e) =>
+ e.preventDefault()
+ @formDisable(e)
+ @resendParams = @formParam(e.target)
- # login check
- App.Auth.loginCheck()
+ @ajax(
+ id: 'email_verify_send'
+ type: 'POST'
+ url: @apiPath + '/users/email_verify_send'
+ data: JSON.stringify(email: @resendParams.email)
+ processData: true
+ success: (data, status, xhr) =>
+ @formEnable(e)
- # add notify
- @notify
- type: 'success'
- msg: App.i18n.translateContent('Thanks for joining. Email sent to "%s". Please verify your email address.', @params.email)
- removeAll: true
+ # add notify
+ @notify
+ type: 'success'
+ msg: App.i18n.translateContent('Email sent to "%s". Please verify your email address.', @params.email)
+ removeAll: true
- # redirect to #
- @navigate '#'
+ if data.token && @Config.get('developer_mode') is true
+ @navigate "#email_verify/#{data.token}"
+ error: @error
+ )
error: (xhr, statusText, error) =>
detailsRaw = xhr.responseText
diff --git a/app/assets/javascripts/app/controllers/user_profile.coffee b/app/assets/javascripts/app/controllers/user_profile.coffee
index 9ea7773cd..1fbfcf5c3 100644
--- a/app/assets/javascripts/app/controllers/user_profile.coffee
+++ b/app/assets/javascripts/app/controllers/user_profile.coffee
@@ -77,6 +77,8 @@ class App.UserProfile extends App.Controller
class ActionRow extends App.ObserverActionRow
model: 'User'
observe:
+ verified: true
+ source: true
organization_id: true
showHistory: (user) =>
@@ -100,6 +102,25 @@ class ActionRow extends App.ObserverActionRow
newTicket: (user) =>
@navigate("ticket/create/customer/#{user.id}")
+ resendVerificationEmail: (user) =>
+ @ajax(
+ id: 'email_verify_send'
+ type: 'POST'
+ url: @apiPath + '/users/email_verify_send'
+ data: JSON.stringify(email: user.email)
+ processData: true
+ success: (data, status, xhr) =>
+ @notify
+ type: 'success'
+ msg: App.i18n.translateContent('Email sent to "%s". Please let the user verify his email address.', user.email)
+ removeAll: true
+ error: (data, status, xhr) =>
+ @notify
+ type: 'error'
+ msg: App.i18n.translateContent('Failed to sent Email "%s". Please contact an administrator.', user.email)
+ removeAll: true
+ )
+
actions: (user) =>
actions = [
{
@@ -121,6 +142,13 @@ class ActionRow extends App.ObserverActionRow
callback: @editUser
}
+ if user.verified isnt true && user.source is 'signup'
+ actions.push({
+ name: 'resend_verification_email'
+ title: 'Resend verification email'
+ callback: @resendVerificationEmail
+ })
+
actions
class Object extends App.ObserverController
diff --git a/app/assets/javascripts/app/controllers/widget/user_signup_check.coffee b/app/assets/javascripts/app/controllers/widget/user_signup_check.coffee
deleted file mode 100644
index e42e3ba6d..000000000
--- a/app/assets/javascripts/app/controllers/widget/user_signup_check.coffee
+++ /dev/null
@@ -1,82 +0,0 @@
-class Widget extends App.Controller
- constructor: ->
-
- # for browser test
- App.Event.bind('user_signup_verify', (user) ->
- new Modal(user: user)
- 'user_signup_verify'
- )
-
- App.Event.bind('auth:login', (user) =>
- return if !user
- @verifyLater(user.id)
- 'user_signup_verify'
- )
- user = App.User.current()
- @verifyLater(user.id) if user?
-
- verifyLater: (userId) =>
- delay = =>
- @verify(userId)
- @delay(delay, 5000, 'user_signup_verify_dialog')
-
- verify: (userId) ->
- return if !userId
- return if !App.User.exists(userId)
- user = App.User.find(userId)
- return if user.source isnt 'signup'
- return if user.verified is true
- currentTime = new Date().getTime()
- createdAt = Date.parse(user.created_at)
- diff = currentTime - createdAt
- max = 1000 * 60 * 30 # show message if account is older then 30 minutes
- return if diff < max
- new Modal(user: user)
-
-class Modal extends App.ControllerModal
- backdrop: false
- keyboard: false
- head: 'Account not verified'
- small: true
- buttonClose: false
- buttonCancel: false
- buttonSubmit: 'Resend verification email'
-
- constructor: ->
- super
-
- content: =>
- if !@sent
- return App.i18n.translateContent('Your account has not been verified. Please click the link in the verification email.')
- content = App.i18n.translateContent('We\'ve sent an email to _%s_. Click the link in the email to verify your account.', @user.email)
- content += '
'
- content += App.i18n.translateContent('If you don\'t see the email, check other places it might be, like your junk, spam, social, or other folders.')
- content
-
- onSubmit: =>
- @ajax(
- id: 'email_verify_send'
- type: 'POST'
- url: @apiPath + '/users/email_verify_send'
- data: JSON.stringify(email: @user.email)
- processData: true
- success: @success
- error: @error
- )
-
- success: (data) =>
- @sent = true
- @update()
-
- # if in developer mode, redirect to verify
- if data.token && @Config.get('developer_mode') is true
- redirect = =>
- @close()
- @navigate "#email_verify/#{data.token}"
- App.Delay.set(redirect, 4000)
-
- error: =>
- @contentInline = App.i18n.translateContent('Unable to send verify email.')
- @update()
-
-App.Config.set('user_signup', Widget, 'Widgets')
diff --git a/app/assets/javascripts/app/views/signup/verify.jst.eco b/app/assets/javascripts/app/views/signup/verify.jst.eco
new file mode 100644
index 000000000..fe9814eae
--- /dev/null
+++ b/app/assets/javascripts/app/views/signup/verify.jst.eco
@@ -0,0 +1,16 @@
+
<%- @T('Thanks for joining. Email sent to "%s".', @email) %>
+<%- @T('Please click the link in the verification email.') %> <%- @T('If you don\'t see the email, check other places it might be, like your junk, spam, social, or other folders.') %>
+ +