Skip to content

Commit fa180ef

Browse files
committed
Login and register functionality
1 parent 0033b1d commit fa180ef

40 files changed

+807
-118
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ end
4343

4444
# Use debugger
4545
gem 'debugger', group: [:development, :test]
46+
47+
gem 'devise'

Gemfile.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ GEM
2727
tzinfo (~> 0.3.37)
2828
arel (4.0.1)
2929
atomic (1.1.14)
30+
bcrypt (3.1.7)
3031
builder (3.1.4)
3132
coffee-rails (4.0.1)
3233
coffee-script (>= 2.2.0)
@@ -42,6 +43,12 @@ GEM
4243
debugger-ruby_core_source (~> 1.2.3)
4344
debugger-linecache (1.2.0)
4445
debugger-ruby_core_source (1.2.4)
46+
devise (3.3.0)
47+
bcrypt (~> 3.0)
48+
orm_adapter (~> 0.1)
49+
railties (>= 3.2.6, < 5)
50+
thread_safe (~> 0.1)
51+
warden (~> 1.2.3)
4552
erubis (2.7.0)
4653
execjs (2.0.2)
4754
hike (1.2.3)
@@ -59,6 +66,7 @@ GEM
5966
mime-types (1.25)
6067
minitest (4.7.5)
6168
multi_json (1.8.2)
69+
orm_adapter (0.5.0)
6270
polyglot (0.3.3)
6371
rack (1.5.2)
6472
rack-test (0.6.2)
@@ -110,13 +118,16 @@ GEM
110118
uglifier (2.3.1)
111119
execjs (>= 0.3.0)
112120
json (>= 1.8.0)
121+
warden (1.2.3)
122+
rack (>= 1.0)
113123

114124
PLATFORMS
115125
ruby
116126

117127
DEPENDENCIES
118128
coffee-rails (~> 4.0.0)
119129
debugger
130+
devise
120131
jbuilder (~> 1.2)
121132
jquery-rails
122133
rails (= 4.0.0)

app/assets/javascripts/home.js.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/home.css.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the home controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/application_controller.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
22
# Prevent CSRF attacks by raising an exception.
33
# For APIs, you may want to use :null_session instead.
44
protect_from_forgery with: :exception
5-
after_action :set_csrf_cookie_for_ng
5+
after_filter :set_csrf_cookie_for_ng
66

77
def intercept_html_requests
88
redirect_to('/') if request.format == Mime::HTML
@@ -11,7 +11,13 @@ def intercept_html_requests
1111
def set_csrf_cookie_for_ng
1212
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
1313
end
14-
14+
15+
rescue_from ActionController::InvalidAuthenticityToken do |exception|
16+
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
17+
message = 'Rails CSRF token error, please try again'
18+
render_with_protection(message.to_json, {:status => :unprocessable_entity})
19+
end
20+
1521
def render_with_protection(object, parameters = {})
1622
render parameters.merge(content_type: 'application/json', text: ")]}',\n" + object.to_json)
1723
end
@@ -20,5 +26,6 @@ def render_with_protection(object, parameters = {})
2026

2127
def verified_request?
2228
super || form_authenticity_token == request.headers['X-XSRF-TOKEN']
23-
end
29+
end
30+
2431
end

app/controllers/clubs_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class ClubsController < ApplicationController
2+
before_filter :authenticate_user!
23
before_filter :intercept_html_requests
34
layout false
45
respond_to :json
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class ConfirmationsController < Devise::ConfirmationsController
2+
3+
protected
4+
5+
def after_confirmation_path_for(resource_name, resource)
6+
'/UI/index.html#login?message=confirm'
7+
end
8+
9+
end

app/controllers/home_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class HomeController < ApplicationController
2+
def index
3+
redirect_to('/UI/index.html')
4+
end
5+
end

app/controllers/teams_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class TeamsController < ApplicationController
2+
before_filter :authenticate_user!
23
before_filter :intercept_html_requests
34
layout false
45
respond_to :json

app/controllers/unlocks_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class UnlocksController < Devise::UnlocksController
2+
3+
protected
4+
5+
def after_unlock_path_for(resource)
6+
'/UI/index.html#login?message=unlock'
7+
end
8+
9+
end

0 commit comments

Comments
 (0)