brightcontent-core 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4728c556a9210324820656f23e9f3f6158e64936452ca928d9caf49aba63792b
4
- data.tar.gz: 5a7255c6d7f22eec541ba1ed0bd7804a1ad7fc9bcd039b460f918dca7e6ed0d7
3
+ metadata.gz: 12c7f53b58837c974cbaa3aa92e6fa884e2ba2f3fdc264121ef1b2ef56dd324d
4
+ data.tar.gz: 7edc026e01dd198e6003a14e3105638ecba9504e1a2aa2b21911216b6b9440e5
5
5
  SHA512:
6
- metadata.gz: 1f011fad510317317fa9fa1f83ca53122c5138efe632aefe16a05ad4b4343c3309c29ae8729630fe86d8a71e7fbd3baa649b094c46caae6cf5e3d4ec66ac5346
7
- data.tar.gz: ee8dee6153c1eaad9ef354590cf34ed8d3b0419bcb79919edc3595b59be88b97bb45dc26afb20f76ee5df2a08726d1a647c64161103cf05ad8bf6f3b1e9003da
6
+ metadata.gz: 4e0e2eef043e8f3ef0634f46f136fc37fb99ad944d3ee076c8cda9ffb6aca3f9c9e2efa868ca97767a6e0b24cea887ef5e6b73ba41acfc466fb94daa9f091c10
7
+ data.tar.gz: 92285171b581c06fba8317f1f6e925df39187d6a1e833dcaf188d5875caa07798aa70602003d6a8b1c752c771017467c1235367a52a7d45042c51c1a8217fa46
@@ -33,7 +33,10 @@ module Brightcontent
33
33
  helper_method :user_resources
34
34
 
35
35
  def authorize
36
- redirect_to login_url unless current_user
36
+ unless current_user
37
+ session[:return_to] = request.original_url
38
+ redirect_to login_url
39
+ end
37
40
  end
38
41
  end
39
42
  end
@@ -5,14 +5,14 @@ module Brightcontent
5
5
  skip_before_action :authorize
6
6
 
7
7
  def new
8
- redirect_to root_url if current_user
8
+ redirect_after_login if current_user
9
9
  end
10
10
 
11
11
  def create
12
12
  user = Brightcontent.user_model.authenticate(params[:email], params[:password])
13
13
  if user
14
14
  session[:brightcontent_user_id] = user.id
15
- redirect_to root_url
15
+ redirect_after_login
16
16
  else
17
17
  flash.now[:danger] = "Email or password is invalid"
18
18
  render :new
@@ -21,7 +21,14 @@ module Brightcontent
21
21
 
22
22
  def destroy
23
23
  session[:brightcontent_user_id] = nil
24
+ session[:return_to] = nil
24
25
  redirect_to root_url
25
26
  end
27
+
28
+ private
29
+
30
+ def redirect_after_login
31
+ redirect_to session.delete(:return_to).presence || root_url
32
+ end
26
33
  end
27
34
  end
@@ -27,6 +27,11 @@ feature "Login" do
27
27
  page.should have_content "Please sign in"
28
28
  end
29
29
 
30
+ scenario "Return to original page after logging in " do
31
+ sign_in "/admin/grouped_blogs"
32
+ current_url.should end_with "/admin/grouped_blogs"
33
+ end
34
+
30
35
  def sign_in_with_invalid_email
31
36
  @user = create(:admin_user)
32
37
  visit "/admin"
@@ -1,6 +1,6 @@
1
- def sign_in
1
+ def sign_in(url = "/admin")
2
2
  user = create(:admin_user)
3
- visit "/admin"
3
+ visit url
4
4
  fill_in "Email", with: user.email
5
5
  fill_in "Password", with: "password"
6
6
  click_button "Login"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightcontent-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Developers at Brightin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-08 00:00:00.000000000 Z
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails