summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
m---------users/app/assets/javascripts/srp0
-rw-r--r--users/app/assets/javascripts/users.js.coffee23
-rw-r--r--users/app/controllers/application_controller.rb14
-rw-r--r--users/app/views/sessions/new.html.haml15
-rw-r--r--users/app/views/users/new.html.haml19
-rw-r--r--users/config/locales/en.yml6
-rw-r--r--users/config/routes.rb6
7 files changed, 53 insertions, 30 deletions
diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp
-Subproject d6a78049f3356d9d645143362eca74434410bf6
+Subproject 5a0ceeb1ca0055719a9b8977a79936216395576
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index 160a7f0..1c00663 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -25,17 +25,20 @@ validate_password = (event) ->
return true
-insert_verifier = (event) ->
- # TODO: verify password confimation
- srp = new SRP
- salt = srp.session.getSalt()
- $('#srp_salt').val(salt)
- $('#srp_password_verifier').val(srp.session.getV().toString(16))
- # clear the password so we do not submit it
- $('#srp_password').val('cleared out - use verifier instead')
- $('#srp_password_confirmation').val('using srp - store verifier')
+signup = (event) ->
+ srp = new SRP(jqueryRest())
+ srp.register()
+ false
+
+login = (event) ->
+ srp = new SRP(jqueryRest())
+ srp.identify ->
+ window.location = '/'
+ false
+
$(document).ready ->
$('#new_user').submit validate_password
- $('#new_user').submit insert_verifier
+ $('#new_user').submit signup
+ $('#new_session').submit login
diff --git a/users/app/controllers/application_controller.rb b/users/app/controllers/application_controller.rb
new file mode 100644
index 0000000..64e1a55
--- /dev/null
+++ b/users/app/controllers/application_controller.rb
@@ -0,0 +1,14 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+
+ private
+
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+ helper_method :current_user
+
+ def authorize
+ redirect_to login_url, alert: "Not authorized" if current_user.nil?
+ end
+end
diff --git a/users/app/views/sessions/new.html.haml b/users/app/views/sessions/new.html.haml
index 39ee7bf..c91d3f2 100644
--- a/users/app/views/sessions/new.html.haml
+++ b/users/app/views/sessions/new.html.haml
@@ -1,7 +1,8 @@
-%h2=t :login
-= simple_form_for :session, :url => sessions_path, :html => { :id => :new_session } do |f|
- %legend=t :login_message
- = f.input :login, :input_html => { :id => :srp_username }
- = f.input :password, :required => true, :input_html => { :id => :srp_password }
- = f.button :submit, :value => t(:login), :class => 'btn-primary'
- = link_to t(:cancel), root_url, :class => :btn
+.span8.offset2
+ %h2=t :login
+ = simple_form_for :session, :url => sessions_path, :html => { :id => :new_session, :class => 'form-horizontal' } do |f|
+ %legend=t :login_message
+ = f.input :login, :input_html => { :id => :srp_username }
+ = f.input :password, :required => true, :input_html => { :id => :srp_password }
+ = f.button :submit, :value => t(:login), :class => 'btn-primary'
+ = link_to t(:cancel), root_url, :class => :btn
diff --git a/users/app/views/users/new.html.haml b/users/app/views/users/new.html.haml
index f6ece3a..835e99a 100644
--- a/users/app/views/users/new.html.haml
+++ b/users/app/views/users/new.html.haml
@@ -1,10 +1,9 @@
-%h2=t :signup
-= simple_form_for @user do |f|
- %legend=t :signup_message
- = f.input :login, :input_html => { :id => :srp_username }
- = f.input :password, :required => true, :input_html => { :id => :srp_password }
- = f.input :password_confirmation, :required => true, :input_html => { :id => :srp_password_confirmation }
- = f.input :password_verifier, :as => :hidden, :input_html => { :id => :srp_password_verifier }
- = f.input :password_salt, :as => :hidden, :input_html => { :id => :srp_salt }
- = f.button :submit, :value => t(:signup), :class => 'btn-primary'
- = link_to t(:cancel), root_url, :class => :btn
+.span8.offset2
+ %h2=t :signup
+ = simple_form_for @user, :html => {:class => 'form-horizontal'} do |f|
+ %legend=t :signup_message
+ = f.input :login, :input_html => { :id => :srp_username }
+ = f.input :password, :required => true, :input_html => { :id => :srp_password }
+ = f.input :password_confirmation, :required => true, :input_html => { :id => :srp_password_confirmation }
+ = f.button :submit, :value => t(:signup), :class => 'btn-primary'
+ = link_to t(:cancel), root_url, :class => :btn
diff --git a/users/config/locales/en.yml b/users/config/locales/en.yml
new file mode 100644
index 0000000..172b85f
--- /dev/null
+++ b/users/config/locales/en.yml
@@ -0,0 +1,6 @@
+en:
+ signup: "Sign up"
+ signup_message: "Please create an account."
+ cancel: "Cancel"
+ login: "Login"
+ login_message: "Please login with your account."
diff --git a/users/config/routes.rb b/users/config/routes.rb
index cfc0407..522c40c 100644
--- a/users/config/routes.rb
+++ b/users/config/routes.rb
@@ -1,10 +1,10 @@
Rails.application.routes.draw do
- get "log_in" => "sessions#new", :as => "log_in"
- get "log_out" => "sessions#destroy", :as => "log_out"
+ get "login" => "sessions#new", :as => "login"
+ get "logout" => "sessions#destroy", :as => "logout"
resources :sessions, :only => [:new, :create, :update, :destroy]
- get "sign_up" => "users#new", :as => "sign_up"
+ get "signup" => "users#new", :as => "signup"
resources :users, :only => [:new, :create]
end