current_me 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -8
- data/lib/current_me.rb +5 -9
- data/lib/current_me/version.rb +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/rooms_controller.rb +1 -3
- data/spec/dummy/app/controllers/sessions_controller.rb +4 -3
- data/spec/dummy/spec/controllers/rooms_controller_spec.rb +1 -1
- data/spec/dummy/spec/controllers/sessions_controller_spec.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -20,22 +20,19 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
### Controllers
|
22
22
|
|
23
|
-
* When signing, use the `
|
23
|
+
* When signing, use the `sign_in`
|
24
24
|
|
25
|
-
|
25
|
+
sign_in user
|
26
|
+
(※`user` needs to be a user model)
|
26
27
|
|
27
28
|
* To Transition to designated page if a user isn't signed in, use the `me!`
|
28
29
|
|
29
30
|
me! signin_path
|
30
31
|
|
31
|
-
* When
|
32
|
-
|
33
|
-
redirect_to come_from
|
34
|
-
|
35
|
-
* When signing out, use the `bye`
|
32
|
+
* When signing out, use the `sign_out`
|
36
33
|
|
37
34
|
def destroy
|
38
|
-
|
35
|
+
sign_out
|
39
36
|
redirect_to :root
|
40
37
|
end
|
41
38
|
|
data/lib/current_me.rb
CHANGED
@@ -21,11 +21,11 @@ module CurrentMe
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def me!(url)
|
24
|
-
unless me?
|
25
|
-
|
24
|
+
redirect_to url unless me?
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
def sign_in(user)
|
28
|
+
self.me = user
|
29
29
|
end
|
30
30
|
|
31
31
|
def me=(user)
|
@@ -35,11 +35,7 @@ module CurrentMe
|
|
35
35
|
@me = user
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def sign_out
|
39
39
|
self.me = nil
|
40
40
|
end
|
41
|
-
|
42
|
-
def come_from
|
43
|
-
session[:come_from]
|
44
|
-
end
|
45
41
|
end
|
data/lib/current_me/version.rb
CHANGED
@@ -3,17 +3,18 @@ class SessionsController < ApplicationController
|
|
3
3
|
end
|
4
4
|
|
5
5
|
def create
|
6
|
+
origin = session[:origin]
|
6
7
|
user = User.find_by_name(params[:name])
|
7
8
|
if user
|
8
|
-
|
9
|
-
redirect_to
|
9
|
+
sign_in user
|
10
|
+
redirect_to origin || user
|
10
11
|
else
|
11
12
|
render 'new'
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def destroy
|
16
|
-
|
17
|
+
sign_out
|
17
18
|
redirect_to root_path
|
18
19
|
end
|
19
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: current_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|