backframe 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/backframe/actioncontroller/acts_as_activation.rb +66 -0
- data/lib/backframe/{acts_as_api → actioncontroller/acts_as_api}/adapter.rb +0 -0
- data/lib/backframe/{acts_as_api → actioncontroller/acts_as_api}/errors.rb +0 -0
- data/lib/backframe/{acts_as_api → actioncontroller/acts_as_api}/headers.rb +0 -0
- data/lib/backframe/{acts_as_api → actioncontroller/acts_as_api}/page.rb +0 -0
- data/lib/backframe/{acts_as_api.rb → actioncontroller/acts_as_api.rb} +6 -4
- data/lib/backframe/actioncontroller/acts_as_reset.rb +81 -0
- data/lib/backframe/{acts_as_resource → actioncontroller/acts_as_resource}/actions.rb +0 -0
- data/lib/backframe/{acts_as_resource.rb → actioncontroller/acts_as_resource.rb} +1 -1
- data/lib/backframe/actioncontroller/acts_as_session.rb +78 -0
- data/lib/backframe/{acts_as_orderable.rb → activerecord/acts_as_orderable.rb} +0 -0
- data/lib/backframe/{acts_as_status.rb → activerecord/acts_as_status.rb} +0 -0
- data/lib/backframe/{acts_as_user.rb → activerecord/acts_as_user.rb} +0 -0
- data/lib/backframe/{filter_sort.rb → activerecord/filter_sort.rb} +0 -0
- data/lib/backframe/{migration.rb → activerecord/migration.rb} +0 -0
- data/lib/backframe/railtie.rb +3 -0
- data/lib/backframe/version.rb +1 -1
- data/lib/backframe.rb +11 -10
- metadata +16 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd277bdfe904479578e2882ecd7feab33d4442aa
|
|
4
|
+
data.tar.gz: a2f3459e626280e5ab56ee51217968714d26a379
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d773393b0da6a44dc3f77b851b3d9b67d345b2fbea972f4d1d7c1856826a51c935563dd85c980c76c0f4021c5c7d58ed6f6985190106b6cc35ad498ff51cfb08
|
|
7
|
+
data.tar.gz: cf566f5e83399fab867a5b9fdaa4e85e924bc0f72023fe0f61d397aa7d938cd5ee892aba3e3d3e84c534674f99212424107ae24fdaabbdcdcc66eac9cbd3f2fa
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
require 'active_support/inflector'
|
|
3
|
+
|
|
4
|
+
module Backframe
|
|
5
|
+
module ActsAsActivation
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
class_methods do
|
|
9
|
+
def acts_as_activation(model, *args)
|
|
10
|
+
|
|
11
|
+
arguments = args[0]
|
|
12
|
+
|
|
13
|
+
class_eval <<-EOV
|
|
14
|
+
|
|
15
|
+
layout 'signin'
|
|
16
|
+
before_action :load_#{model.underscore}, :except => :show
|
|
17
|
+
|
|
18
|
+
def show
|
|
19
|
+
@activation = Activation.find_by(:token => params[:token])
|
|
20
|
+
if @activation.nil?
|
|
21
|
+
flash[:error] = I18n.t(:activation_invalid)
|
|
22
|
+
redirect_to account_signin_path
|
|
23
|
+
elsif @activation.expired?
|
|
24
|
+
flash[:error] = I18n.t(:activation_expired)
|
|
25
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
26
|
+
else
|
|
27
|
+
session.delete(:#{model.underscore}_id)
|
|
28
|
+
session[:activation_id] = @activation.id
|
|
29
|
+
flash[:success] = I18n.t(:activation_success)
|
|
30
|
+
redirect_to '#{arguments[:prefix]}/activation/password'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def password
|
|
35
|
+
if request.patch?
|
|
36
|
+
@user.set_password = true
|
|
37
|
+
@user.attributes = params.require(:#{model.underscore}).permit([:new_password,:confirm_password])
|
|
38
|
+
if @user.save!
|
|
39
|
+
session.delete(:activation_id)
|
|
40
|
+
session[:#{model.underscore}_id] = @user.id
|
|
41
|
+
@activation.claim
|
|
42
|
+
redirect_to '#{arguments[:redirect]}'
|
|
43
|
+
else
|
|
44
|
+
flash[:error] = @user.errors[:new_password].first
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def load_#{model.underscore}
|
|
52
|
+
@activation = Activation.find_by(:id => session[:activation_id])
|
|
53
|
+
@user = @activation.user
|
|
54
|
+
if @user.nil?
|
|
55
|
+
flash[:error] = I18n.t(:activation_invalid)
|
|
56
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
EOV
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
require 'write_xlsx'
|
|
2
|
+
|
|
1
3
|
require 'active_support'
|
|
2
4
|
require 'active_support/inflector'
|
|
3
5
|
require 'active_model_serializers'
|
|
4
6
|
|
|
5
|
-
require 'backframe/acts_as_api/adapter'
|
|
6
|
-
require 'backframe/acts_as_api/errors'
|
|
7
|
-
require 'backframe/acts_as_api/headers'
|
|
8
|
-
require 'backframe/acts_as_api/page'
|
|
7
|
+
require 'backframe/actioncontroller/acts_as_api/adapter'
|
|
8
|
+
require 'backframe/actioncontroller/acts_as_api/errors'
|
|
9
|
+
require 'backframe/actioncontroller/acts_as_api/headers'
|
|
10
|
+
require 'backframe/actioncontroller/acts_as_api/page'
|
|
9
11
|
|
|
10
12
|
module Backframe
|
|
11
13
|
module ActsAsAPI
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
require 'active_support/inflector'
|
|
3
|
+
|
|
4
|
+
module Backframe
|
|
5
|
+
module ActsAsReset
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
class_methods do
|
|
9
|
+
def acts_as_reset(model, *args)
|
|
10
|
+
|
|
11
|
+
arguments = args[0]
|
|
12
|
+
|
|
13
|
+
class_eval <<-EOV
|
|
14
|
+
|
|
15
|
+
layout 'signin'
|
|
16
|
+
before_action :redirect_if_signed_in
|
|
17
|
+
before_action :load_#{model.underscore}, :except => [:new,:show]
|
|
18
|
+
|
|
19
|
+
def new
|
|
20
|
+
if request.post?
|
|
21
|
+
@user = #{model}.find_by_email(params[:#{model.underscore}][:email])
|
|
22
|
+
if @user && @user.reset
|
|
23
|
+
flash[:error] = I18n.t(:reset_request)
|
|
24
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
25
|
+
else
|
|
26
|
+
flash[:error] = I18n.t(:reset_not_found)
|
|
27
|
+
redirect_to '#{arguments[:prefix]}/reset'
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
@user = #{model}.new
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def show
|
|
35
|
+
@reset = Reset.find_by(:token => params[:token])
|
|
36
|
+
if @reset.nil?
|
|
37
|
+
flash[:error] = I18n.t(:reset_invalid)
|
|
38
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
39
|
+
elsif @reset.expired?
|
|
40
|
+
flash[:error] = I18n.t(:reset_expired)
|
|
41
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
42
|
+
else
|
|
43
|
+
@reset.claim
|
|
44
|
+
session[:reset_id] = @reset.user.id
|
|
45
|
+
flash[:error] = I18n.t(:reset_password)
|
|
46
|
+
redirect_to '#{arguments[:prefix]}/reset/password'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def password
|
|
51
|
+
if request.patch?
|
|
52
|
+
@user.set_password = true
|
|
53
|
+
@user.attributes = params.require(:#{model.underscore}).permit([:new_password,:confirm_password])
|
|
54
|
+
if @user.save
|
|
55
|
+
session.delete(:reset_id)
|
|
56
|
+
session[:#{model.underscore}_id] = @user.id
|
|
57
|
+
flash[:error] = I18n.t(:reset_success)
|
|
58
|
+
redirect_to '#{arguments[:redirect]}'
|
|
59
|
+
else
|
|
60
|
+
flash[:error] = @user.errors[:new_password].first
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def load_#{model.underscore}
|
|
68
|
+
@user = #{model}.find_by(:id => session[:reset_id])
|
|
69
|
+
if @user.nil?
|
|
70
|
+
flash[:error] = I18n.t(:reset_invalid)
|
|
71
|
+
redirect_to account_signin_path
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
EOV
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
require 'active_support/inflector'
|
|
3
|
+
|
|
4
|
+
module Backframe
|
|
5
|
+
module ActsAsSession
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
class_methods do
|
|
9
|
+
def acts_as_session(model, *args)
|
|
10
|
+
|
|
11
|
+
arguments = args[0]
|
|
12
|
+
|
|
13
|
+
class_eval <<-EOV
|
|
14
|
+
|
|
15
|
+
layout 'signin'
|
|
16
|
+
before_action :redirect_if_signed_in, :except => [:application,:destroy]
|
|
17
|
+
before_action :authenticate_#{model.underscore}, :only => :application
|
|
18
|
+
|
|
19
|
+
def application
|
|
20
|
+
render :layout => false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def new
|
|
24
|
+
@user = #{model}.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create
|
|
28
|
+
if @user = #{model}.find_by_email(params[:#{model.underscore}][:email])
|
|
29
|
+
if @user.locked_out?
|
|
30
|
+
flash[:error] = I18n.t(:session_locked)
|
|
31
|
+
session[:signin_locked] = true
|
|
32
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
33
|
+
elsif @user.authenticate(params[:#{model.underscore}][:password])
|
|
34
|
+
@user.signin(:success)
|
|
35
|
+
session.delete(:signin_locked)
|
|
36
|
+
session[:#{model.underscore}_id] = @user.id
|
|
37
|
+
url = session[:redirect_to] || '#{arguments[:redirect]}'
|
|
38
|
+
redirect_to url
|
|
39
|
+
else
|
|
40
|
+
@user.signin(:failed)
|
|
41
|
+
if @user.locked_out?
|
|
42
|
+
session[:signin_locked] = true
|
|
43
|
+
flash[:error] = I18n.t(:session_locking)
|
|
44
|
+
else
|
|
45
|
+
flash[:error] = I18n.t(:session_invalid)
|
|
46
|
+
end
|
|
47
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
flash[:error] = I18n.t(:session_not_found)
|
|
51
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def destroy
|
|
56
|
+
flash[:success] = I18n.t(:session_signout)
|
|
57
|
+
session.delete(:redirect_to)
|
|
58
|
+
session.delete(:#{model.underscore}_id)
|
|
59
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def authenticate_#{model.underscore}
|
|
65
|
+
if !signed_in?
|
|
66
|
+
flash[:warning] = I18n.t(:session_interception)
|
|
67
|
+
session[:redirect_to] = request.path
|
|
68
|
+
redirect_to '#{arguments[:prefix]}/signin'
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
EOV
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/backframe/railtie.rb
CHANGED
|
@@ -3,6 +3,9 @@ module Backframe
|
|
|
3
3
|
initializer 'backframe' do |_app|
|
|
4
4
|
ActionController::Base.send(:include, Backframe::ActsAsAPI)
|
|
5
5
|
ActionController::Base.send(:include, Backframe::ActsAsResource)
|
|
6
|
+
ActionController::Base.send(:include, Backframe::ActsAsActivation)
|
|
7
|
+
ActionController::Base.send(:include, Backframe::ActsAsReset)
|
|
8
|
+
ActionController::Base.send(:include, Backframe::ActsAsSession)
|
|
6
9
|
ActiveRecord::Base.send(:include, Backframe::ActsAsOrderable)
|
|
7
10
|
ActiveRecord::Base.send(:include, Backframe::ActsAsStatus)
|
|
8
11
|
ActiveRecord::Base.send(:include, Backframe::ActsAsUser)
|
data/lib/backframe/version.rb
CHANGED
data/lib/backframe.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require 'backframe/
|
|
2
|
-
require 'backframe/
|
|
3
|
-
require 'backframe/
|
|
4
|
-
require 'backframe/
|
|
5
|
-
require 'backframe/
|
|
6
|
-
require 'backframe/
|
|
7
|
-
require 'backframe/acts_as_status'
|
|
8
|
-
require 'backframe/acts_as_user'
|
|
9
|
-
require 'backframe/
|
|
10
|
-
require '
|
|
1
|
+
require 'backframe/actioncontroller/acts_as_activation'
|
|
2
|
+
require 'backframe/actioncontroller/acts_as_api'
|
|
3
|
+
require 'backframe/actioncontroller/acts_as_reset'
|
|
4
|
+
require 'backframe/actioncontroller/acts_as_resource'
|
|
5
|
+
require 'backframe/actioncontroller/acts_as_session'
|
|
6
|
+
require 'backframe/activerecord/acts_as_orderable'
|
|
7
|
+
require 'backframe/activerecord/acts_as_status'
|
|
8
|
+
require 'backframe/activerecord/acts_as_user'
|
|
9
|
+
require 'backframe/activerecord/filter_sort'
|
|
10
|
+
require 'backframe/activerecord/migration'
|
|
11
11
|
|
|
12
12
|
module Backframe
|
|
13
13
|
module Exceptions
|
|
@@ -17,5 +17,6 @@ module Backframe
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
if defined? Rails
|
|
20
|
+
require 'backframe/mime'
|
|
20
21
|
require 'backframe/railtie'
|
|
21
22
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: backframe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Kops
|
|
@@ -95,18 +95,21 @@ files:
|
|
|
95
95
|
- backframe.gemspec
|
|
96
96
|
- circle.yml
|
|
97
97
|
- lib/backframe.rb
|
|
98
|
-
- lib/backframe/
|
|
99
|
-
- lib/backframe/acts_as_api
|
|
100
|
-
- lib/backframe/acts_as_api/
|
|
101
|
-
- lib/backframe/acts_as_api/
|
|
102
|
-
- lib/backframe/acts_as_api/
|
|
103
|
-
- lib/backframe/
|
|
104
|
-
- lib/backframe/
|
|
105
|
-
- lib/backframe/acts_as_resource
|
|
106
|
-
- lib/backframe/
|
|
107
|
-
- lib/backframe/
|
|
108
|
-
- lib/backframe/
|
|
109
|
-
- lib/backframe/
|
|
98
|
+
- lib/backframe/actioncontroller/acts_as_activation.rb
|
|
99
|
+
- lib/backframe/actioncontroller/acts_as_api.rb
|
|
100
|
+
- lib/backframe/actioncontroller/acts_as_api/adapter.rb
|
|
101
|
+
- lib/backframe/actioncontroller/acts_as_api/errors.rb
|
|
102
|
+
- lib/backframe/actioncontroller/acts_as_api/headers.rb
|
|
103
|
+
- lib/backframe/actioncontroller/acts_as_api/page.rb
|
|
104
|
+
- lib/backframe/actioncontroller/acts_as_reset.rb
|
|
105
|
+
- lib/backframe/actioncontroller/acts_as_resource.rb
|
|
106
|
+
- lib/backframe/actioncontroller/acts_as_resource/actions.rb
|
|
107
|
+
- lib/backframe/actioncontroller/acts_as_session.rb
|
|
108
|
+
- lib/backframe/activerecord/acts_as_orderable.rb
|
|
109
|
+
- lib/backframe/activerecord/acts_as_status.rb
|
|
110
|
+
- lib/backframe/activerecord/acts_as_user.rb
|
|
111
|
+
- lib/backframe/activerecord/filter_sort.rb
|
|
112
|
+
- lib/backframe/activerecord/migration.rb
|
|
110
113
|
- lib/backframe/mime.rb
|
|
111
114
|
- lib/backframe/railtie.rb
|
|
112
115
|
- lib/backframe/version.rb
|