|
@@ -11,26 +11,53 @@ class Index extends App.Controller
|
|
|
super
|
|
|
|
|
|
# check authentication
|
|
|
- return if !@authenticate()
|
|
|
+# return if !@authenticate()
|
|
|
|
|
|
# set title
|
|
|
@title 'Get Started'
|
|
|
+ @navupdate '#get_started'
|
|
|
+
|
|
|
+ @master_user = 0
|
|
|
+
|
|
|
+# @render()
|
|
|
+ @fetch()
|
|
|
|
|
|
- @render()
|
|
|
+ fetch: ->
|
|
|
+
|
|
|
+ # get data
|
|
|
+ @ajax = new App.Ajax
|
|
|
+ @ajax.ajax(
|
|
|
+ type: 'GET',
|
|
|
+ url: '/getting_started',
|
|
|
+ data: {
|
|
|
+# view: @view,
|
|
|
+ }
|
|
|
+ processData: true,
|
|
|
+ success: (data, status, xhr) =>
|
|
|
+
|
|
|
+ # get meta data
|
|
|
+ @master_user = data.master_user
|
|
|
+
|
|
|
+ # load group collection
|
|
|
+ @loadCollection( type: 'Group', data: data.groups )
|
|
|
+
|
|
|
+ # load role collection
|
|
|
+ @loadCollection( type: 'Role', data: data.roles )
|
|
|
+
|
|
|
+ # render page
|
|
|
+ @render()
|
|
|
+ )
|
|
|
|
|
|
- @navupdate '#get_started'
|
|
|
-
|
|
|
render: ->
|
|
|
@html App.view('getting_started')(
|
|
|
- form: @formGen( model: App.User, required: 'invite_agent' ),
|
|
|
+ form_agent: @formGen( model: App.User, required: 'invite_agent' ),
|
|
|
+ form_master: @formGen( model: App.User, required: 'signup' ),
|
|
|
+ master_user: @master_user,
|
|
|
)
|
|
|
-
|
|
|
- cancel: ->
|
|
|
- @log 'cancel....'
|
|
|
- @navigate 'login'
|
|
|
+ if !@master_user
|
|
|
+ @el.find('.agent_user').removeClass('hide')
|
|
|
|
|
|
submit: (e) ->
|
|
|
- @log 'submit'
|
|
|
e.preventDefault()
|
|
|
@params = @formParam(e.target)
|
|
|
|
|
@@ -38,13 +65,16 @@ class Index extends App.Controller
|
|
|
if !@params.login && @params.email
|
|
|
@params.login = @params.email
|
|
|
|
|
|
- # find agent role
|
|
|
- role = App.Role.findByAttribute("name", "Agent")
|
|
|
- @params.role_ids = role.id
|
|
|
-
|
|
|
# set invite flag
|
|
|
@params.invite = true
|
|
|
|
|
|
+ # find agent role
|
|
|
+ role = App.Role.findByAttribute("name", "Agent")
|
|
|
+ if role
|
|
|
+ @params.role_ids = role.id
|
|
|
+ else
|
|
|
+ @params.role_ids = [0]
|
|
|
+
|
|
|
@log 'updateAttributes', @params
|
|
|
user = new App.User
|
|
|
user.load(@params)
|
|
@@ -61,14 +91,41 @@ class Index extends App.Controller
|
|
|
# send email
|
|
|
|
|
|
# clear form
|
|
|
- @render()
|
|
|
+# @fetch()
|
|
|
+ auth = new App.Auth
|
|
|
+ auth.login(
|
|
|
+ data: {
|
|
|
+ username: @params.login,
|
|
|
+ password: @params.password,
|
|
|
+ },
|
|
|
+ success: @success
|
|
|
+# error: @error,
|
|
|
+ )
|
|
|
# error: =>
|
|
|
# @modalHide()
|
|
|
)
|
|
|
|
|
|
-Config.Routes['getting_started'] = Index
|
|
|
|
|
|
-#class App.GetStarted extends App.Router
|
|
|
-# routes:
|
|
|
-# 'getting_started': Index
|
|
|
-#Config.Controller.push App.GetStarted;
|
|
|
+ success: (data, status, xhr) =>
|
|
|
+ @log 'login:success', data
|
|
|
+
|
|
|
+ if @master_user
|
|
|
+ # login check
|
|
|
+ auth = new App.Auth
|
|
|
+ auth.loginCheck()
|
|
|
+
|
|
|
+ # add notify
|
|
|
+ Spine.trigger 'notify:removeall'
|
|
|
+# @notify
|
|
|
+# type: 'success',
|
|
|
+# msg: 'Thanks for joining. Email sent to "' + @params.email + '". Please verify your email address.'
|
|
|
+
|
|
|
+ @el.find('.master_user').fadeOut('slow', =>
|
|
|
+ @el.find('.agent_user').fadeIn()
|
|
|
+ )
|
|
|
+ # redirect to #
|
|
|
+# @navigate '#getting_started'
|
|
|
+# @fetch()
|
|
|
+
|
|
|
+
|
|
|
+Config.Routes['getting_started'] = Index
|