Skip to content

Commit 697884c

Browse files
committedApr 14, 2016
Fix logging in to work and add flashes
1 parent efcc248 commit 697884c

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed
 

‎app/assets/stylesheets/application.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
1111
* file per style scope.
1212
*
13-
*= require bootstrap/dist/css/bootstrap.min.css
13+
*= require flashes.css
1414
*= require bootstrap/dist/css/bootstrap-theme.min.css
1515
*= require_self
1616
*/

‎app/assets/stylesheets/application.css.scss

-8
This file was deleted.

‎app/controllers/sessions_controller.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ class SessionsController < ApplicationController
44
def create
55
auth_hash = request.env['omniauth.auth']
66

7-
render :text => auth_hash.inspect
8-
97
begin
108
@user = User.from_omniauth(request.env['omniauth.auth'])
119
session[:user_id] = @user.id
1210
flash[:success] = "Welcome, #{@user.name}!"
13-
rescue
11+
rescue Exception => e
12+
puts e.message
1413
flash[:warning] = "There was an error while trying to authenticate you..."
1514
end
1615
redirect_to root_path

‎app/models/user.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class User < ActiveRecord::Base
2-
def from_omniauth(auth_hash)
2+
def self.from_omniauth(auth_hash)
33
user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
44
user.name = auth_hash['info']['name']
55
user.email = auth_hash['info']['email']
6-
#user.location = auth_hash['info']['location']
6+
# user.location = auth_hash['info']['location']
77
user.image_url = auth_hash['info']['image']
88
# user.url = auth_hash['info']['urls']['Twitter']
99
user.save!
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
p
2+
= 'Flashes go here'
13
- if flash.any?
24
.flashes
35
- user_facing_flashes.each do |key, value|
4-
| <div class="flash-
6+
| <div class="alert alert-dismissible flash flash-
57
= key
6-
| ">
8+
| " role="alert">
79
= value

‎app/views/questions/index.html.slim

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ h1
2929
= link_to 'View Starter File', starter_file_question_path(question.id)
3030

3131
.container
32-
= link_to 'Admin Login', '/auth/google'
32+
- if current_user
33+
= link_to 'Logout', '/logout', method: :delete
34+
- else
35+
= link_to 'Admin Login', '/auth/google'

‎bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"jquery-ujs": "~1.x.x",
1414
"bootstrap": "~3.x.x",
1515
"font-awesome": "~4.x.x",
16-
"underscore": "^1.8.3"
16+
"underscore": "^1.8.3",
17+
"bootstrap-sass": "^3.3.6"
1718
}
1819
}

0 commit comments

Comments
 (0)
Please sign in to comment.