chaltron 0.1.2 → 0.1.3
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/README.md +22 -12
- data/Rakefile +3 -0
- data/app/assets/javascripts/chaltron/datatables.js.coffee +13 -16
- data/app/assets/javascripts/chaltron/datatables.js.coffee~ +106 -0
- data/app/assets/javascripts/chaltron.js +4 -4
- data/app/assets/javascripts/chaltron.js~ +13 -0
- data/app/assets/javascripts/dataTables/dataTables.bootstrap.min.js +8 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.responsive.min.js +19 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.select.min.js +23 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.min.js +163 -0
- data/app/assets/stylesheets/chaltron.scss +4 -4
- data/app/assets/stylesheets/dataTables/dataTables.bootstrap.css +167 -0
- data/app/assets/stylesheets/dataTables/extras/responsive.bootstrap.css +106 -0
- data/app/assets/stylesheets/dataTables/extras/select.dataTables.css +100 -0
- data/app/helpers/chaltron/ldap_helper.rb +3 -3
- data/app/helpers/chaltron_helper.rb +15 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/lib/chaltron/engine.rb +0 -1
- data/lib/chaltron/ldap/person.rb +1 -1
- data/lib/chaltron/version.rb +1 -1
- data/lib/generators/chaltron/templates/app/views/layouts/_footer.html.erb +10 -0
- data/lib/generators/chaltron/templates/app/views/layouts/application.html.erb +1 -0
- data/lib/templates/erb/scaffold/index.html.erb +1 -16
- data/lib/templates/erb/scaffold/index.html.erb~ +28 -0
- metadata +13 -31
- data/app/assets/stylesheets/chaltron/datatables.scss +0 -14
- data/app/assets/stylesheets/chaltron/layout.scss~ +0 -68
- data/app/controllers/chaltron/omniauth_callbacks_controller.rb~ +0 -34
- data/app/controllers/chaltron/users_controller.rb~ +0 -94
- data/app/models/user.rb~ +0 -28
- data/app/views/chaltron/users/index.html.erb~ +0 -48
- data/app/views/devise/sessions/_new_ldap.html.erb~ +0 -31
- data/app/views/devise/sessions/_new_local.html.erb~ +0 -20
- data/app/views/locales/en.yml~ +0 -91
- data/app/views/locales/it.yml~ +0 -91
- data/config/initializers/devise.rb~ +0 -256
- data/lib/chaltron/controllers/helpers.rb~ +0 -61
- data/lib/chaltron/engine.rb~ +0 -47
- data/lib/chaltron/ldap/user.rb~ +0 -88
- data/lib/chaltron/version.rb~ +0 -3
data/lib/chaltron/ldap/user.rb~
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# LDAP extension for User ::User
|
|
2
|
-
#
|
|
3
|
-
# * Find or create user from omniauth.auth data
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
require 'chaltron/ldap/person'
|
|
7
|
-
|
|
8
|
-
module Chaltron
|
|
9
|
-
module LDAP
|
|
10
|
-
class User
|
|
11
|
-
class << self
|
|
12
|
-
attr_reader :auth
|
|
13
|
-
|
|
14
|
-
def find_or_create(auth, create)
|
|
15
|
-
@auth = auth
|
|
16
|
-
if uid.blank? || email.blank? || username.blank?
|
|
17
|
-
raise_error('Account must provide a dn, uid and email address')
|
|
18
|
-
end
|
|
19
|
-
user = find_by_uid_and_provider
|
|
20
|
-
|
|
21
|
-
puts "DEBUG user = #{user}"
|
|
22
|
-
|
|
23
|
-
entry = Chaltron::LDAP::Person.find_by_uid(username)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
puts "DEBUG entry = #{entry}"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if user.nil? and create
|
|
30
|
-
# create user
|
|
31
|
-
user = entry.create_user Chaltron.default_roles
|
|
32
|
-
end
|
|
33
|
-
update_ldap_attributes(user, entry) unless user.nil?
|
|
34
|
-
user
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
def update_ldap_attributes(user, entry)
|
|
40
|
-
user.update_attributes!(
|
|
41
|
-
email: entry.email,
|
|
42
|
-
department: entry.department
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def find_by_uid_and_provider
|
|
47
|
-
# LDAP distinguished name is case-insensitive
|
|
48
|
-
user = ::User.where('provider = ? and lower(extern_uid) = ?', provider, uid.downcase).last
|
|
49
|
-
if user.nil?
|
|
50
|
-
# Look for user with same emails
|
|
51
|
-
#
|
|
52
|
-
# Possible cases:
|
|
53
|
-
# * When user already has account and need to link their LDAP account.
|
|
54
|
-
# * LDAP uid changed for user with same email and we need to update their uid
|
|
55
|
-
#
|
|
56
|
-
user = ::User.find_by(email: email)
|
|
57
|
-
user.update_attributes!(extern_uid: uid, provider: provider) unless user.nil?
|
|
58
|
-
end
|
|
59
|
-
user
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def uid
|
|
63
|
-
auth.info.uid || auth.uid
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def email
|
|
67
|
-
auth.info.email.downcase unless auth.info.email.nil?
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def name
|
|
71
|
-
auth.info.name.to_s.force_encoding('utf-8')
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def username
|
|
75
|
-
auth.info.nickname.to_s.force_encoding('utf-8')
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def provider
|
|
79
|
-
'ldap'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def raise_error(message)
|
|
83
|
-
fail OmniAuth::Error, '(LDAP) ' + message
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
data/lib/chaltron/version.rb~
DELETED