diff --git a/Gemfile.lock b/Gemfile.lock index 05b682254..a522c2d2d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GEM - remote: https://rubygems.org/ + remote: http://rubygems.org/ specs: actionmailer (3.2.2) actionpack (= 3.2.2) @@ -28,6 +28,7 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) + addressable (2.2.7) arel (3.0.2) builder (3.0.0) coffee-rails (3.2.2) @@ -37,9 +38,25 @@ GEM coffee-script-source execjs coffee-script-source (1.2.0) + daemons (1.1.8) + delayed_job (3.0.1) + activesupport (~> 3.0) + delayed_job_active_record (0.3.2) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + eco (1.0.0) + coffee-script + eco-source + execjs + eco-source (1.1.0.rc.1) erubis (2.7.0) execjs (1.3.0) multi_json (~> 1.0) + faraday (0.7.6) + addressable (~> 2.2) + multipart-post (~> 1.1) + rack (~> 1.1) + hashie (1.2.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) @@ -47,12 +64,35 @@ GEM railties (>= 3.2.0, < 5.0) thor (~> 0.14) json (1.6.6) + koala (1.3.0) + faraday (~> 0.7.0) + multi_json (~> 1.0) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.18) multi_json (1.2.0) + multipart-post (1.1.5) + oauth (0.4.5) + oauth2 (0.5.2) + faraday (~> 0.7) + multi_json (~> 1.0) + omniauth (1.0.2) + hashie (~> 1.2) + rack + omniauth-facebook (1.2.0) + omniauth-oauth2 (~> 1.0.0) + omniauth-linkedin (0.0.6) + omniauth-oauth (~> 1.0.0) + omniauth-oauth (1.0.0) + oauth + omniauth (~> 1.0) + omniauth-oauth2 (1.0.0) + oauth2 (~> 0.5.0) + omniauth (~> 1.0) + omniauth-twitter (0.0.8) + omniauth-oauth (~> 1.0) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -84,6 +124,7 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + simple_oauth (0.1.5) sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) @@ -94,6 +135,11 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) + twitter (2.1.0) + activesupport (>= 2.3.9, < 4) + faraday (~> 0.7) + multi_json (~> 1.0) + simple_oauth (~> 0.1) tzinfo (0.3.32) uglifier (1.2.4) execjs (>= 0.3.0) @@ -103,10 +149,21 @@ PLATFORMS ruby DEPENDENCIES - coffee-rails (~> 3.2.1) + coffee-rails (~> 3.2.2) + daemons + delayed_job_active_record + eco jquery-rails json + koala + mail + mime-types + omniauth + omniauth-facebook + omniauth-linkedin + omniauth-twitter rails (= 3.2.2) - sass-rails (~> 3.2.3) + sass-rails (~> 3.2.4) sqlite3 - uglifier (>= 1.0.3) + twitter + uglifier (>= 1.2.3) diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index f9b4398a7..93d1e9544 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -11,26 +11,53 @@ class Index extends App.Controller super # check authentication - return if !@authenticate() +# return if !@authenticate() # set title @title 'Get Started' - - @render() - @navupdate '#get_started' - - render: -> - @html App.view('getting_started')( - form: @formGen( model: App.User, required: 'invite_agent' ), + + @master_user = 0 + +# @render() + @fetch() + + 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() ) - cancel: -> - @log 'cancel....' - @navigate 'login' + render: -> + @html App.view('getting_started')( + form_agent: @formGen( model: App.User, required: 'invite_agent' ), + form_master: @formGen( model: App.User, required: 'signup' ), + master_user: @master_user, + ) + 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; \ No newline at end of file + 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 diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index 6f137d4f1..368f914af 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -92,6 +92,21 @@ class App.Auth extends App.Ajax success: (data, status, xhr) => console.log 'logincheck:success', data + # if session is not valid + if data.error + + # update config + for key, value of data.config + window.Config[key] = value + + # empty session + window.Session = {} + + # rebuild navbar with new navbar items + Spine.trigger 'navrebuild' + + return false; + # set avatar if !data.session.image data.session.image = 'http://placehold.it/48x48' diff --git a/app/assets/javascripts/app/views/getting_started.jst.eco b/app/assets/javascripts/app/views/getting_started.jst.eco index 428e076a5..561994d4b 100644 --- a/app/assets/javascripts/app/views/getting_started.jst.eco +++ b/app/assets/javascripts/app/views/getting_started.jst.eco @@ -4,12 +4,21 @@