radiant-users-extension 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,13 +5,13 @@ module Users
5
5
  def self.included(base)
6
6
  base.class_eval do
7
7
  attr_protected :access
8
- after_create :generate_api_key
8
+ after_initialize :generate_api_key
9
9
 
10
10
  def generate_api_key
11
11
  begin
12
- self.api_key = self.sha1(Time.now + Radiant::Config['session_timeout'].to_i)
12
+ self.api_key = ActiveSupport::SecureRandom.hex(18) unless api_key.present?
13
13
  rescue
14
- logger.error "attempt to create api key failed - please migrate radiant-scoped-extension"
14
+ logger.error "attempt to create api key failed - please migrate radiant-users-extension"
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,47 @@
1
+ module Users
2
+ module Tags
3
+ module Core
4
+ include Radiant::Taggable
5
+
6
+ tag 'user' do |tag|
7
+ return if tag.locals.page.cache?
8
+
9
+ tag.locals.user = Helpers.current_user(tag)
10
+
11
+ tag.expand
12
+ end
13
+
14
+ tag 'user:if_user' do |tag|
15
+ tag.expand if tag.locals.user.present?
16
+ end
17
+
18
+ tag 'user:unless_user' do |tag|
19
+ tag.expand unless tag.locals.user.present?
20
+ end
21
+
22
+ tag 'user:if_authorized' do |tag|
23
+ tag.expand unless tag.locals.user.access.present?
24
+ end
25
+
26
+ tag 'user:unless_authorized' do |tag|
27
+ tag.expand if tag.locals.user.access.present?
28
+ end
29
+
30
+ tag 'user:if_admin' do |tag|
31
+ tag.expand if tag.locals.user.admin
32
+ end
33
+
34
+ tag 'user:unless_admin' do |tag|
35
+ tag.expand unless tag.locals.user.admin
36
+ end
37
+
38
+ [:name, :first_name, :last_name, :login, :email, :access].each do |symbol|
39
+ desc %{ outputs the #{symbol} of the current user }
40
+ tag "user:#{symbol}" do |tag|
41
+ tag.locals.user.send(symbol)
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ module Users
2
+ module Tags
3
+ class Helpers
4
+ class << self
5
+ include ActionView::Helpers::NumberHelper
6
+
7
+ def current_user(tag)
8
+ begin
9
+ user_id = tag.locals.page.request.session['user_id']
10
+ User.find(user_id)
11
+ rescue
12
+ return false
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-users-extension}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christopher Rankin", "Dirk Kelly"]
12
- s.date = %q{2010-11-30}
12
+ s.date = %q{2010-12-14}
13
13
  s.description = %q{Users creates support for non-admin users with API access}
14
14
  s.email = %q{dk@squaretalent.com}
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/users/lib/login_system.rb",
31
31
  "lib/users/models/user.rb",
32
32
  "lib/users/models/user/scoped.rb",
33
+ "lib/users/tags/core.rb",
34
+ "lib/users/tags/helpers.rb",
33
35
  "radiant-users-extension.gemspec",
34
36
  "spec/datasets/scoped_users_dataset.rb",
35
37
  "spec/models/user_spec.rb",
data/users_extension.rb CHANGED
@@ -4,6 +4,9 @@ class UsersExtension < Radiant::Extension
4
4
  url "http://github.com/dirkkelly/radiant-users-extension"
5
5
 
6
6
  def activate
7
+ # Tags
8
+ Page.send :include, Users::Tags::Core
9
+
7
10
  # Models
8
11
  User.send :include, Users::Models::User
9
12
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-users-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Rankin
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-30 00:00:00 +08:00
19
+ date: 2010-12-14 00:00:00 +08:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -43,6 +43,8 @@ files:
43
43
  - lib/users/lib/login_system.rb
44
44
  - lib/users/models/user.rb
45
45
  - lib/users/models/user/scoped.rb
46
+ - lib/users/tags/core.rb
47
+ - lib/users/tags/helpers.rb
46
48
  - radiant-users-extension.gemspec
47
49
  - spec/datasets/scoped_users_dataset.rb
48
50
  - spec/models/user_spec.rb