Skip to content

Commit f77d06a

Browse files
author
Nicholas W. Watson
committed
Merge pull request #17 from nwwatson/master
Small changes made to authentication
2 parents 9f7c54d + c462df3 commit f77d06a

File tree

11 files changed

+185
-31
lines changed

11 files changed

+185
-31
lines changed

app/controllers/entropi_social/user_registrations_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def create
1212
@user = User.new(params[:user])
1313

1414
if @user.save
15+
16+
flash[:notice] = I18n.t("devise.registrations.signed_up")
17+
1518
sign_in_and_redirect(:user, @user)
1619
else
1720
clean_up_passwords(@user)

app/models/asset_photo.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class AssetPhoto < ActiveRecord::Base
22
belongs_to :photoable, :polymorphic => true
33
belongs_to :photo
4-
end
4+
end
5+

app/views/entropi_social/user_sessions/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="modal active">
1+
<div class="modal active well">
22
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
33
<div class="modal-header">
44
<h3>Log In</h3>

config/initializers/devise.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,6 @@
7070

7171
# Setup a pepper to generate the encrypted password.
7272
# config.pepper = "1b7f9bac66e61d8d7fa8fe02c5ca25fc7c774ec4b1e1a56117e8eec0f53fb6f66f6d03b85ab727dd7cc314516ead92e8792a995fc9120a273790b0f8382067b8"
73-
74-
# ==> Configuration for :invitable
75-
# The period the generated invitation token is valid, after
76-
# this period, the invited resource won't be able to accept the invitation.
77-
# When invite_for is 0 (the default), the invitation won't expire.
78-
config.invite_for = 3.weeks
79-
80-
# Number of invitations users can send.
81-
# If invitation_limit is nil, users can send unlimited invitations.
82-
# If invitation_limit is 0, users can't send invitations.
83-
# If invitation_limit n > 0, users can send n invitations.
84-
# Default: nil
85-
config.invitation_limit = 15
86-
87-
# The key to be used to check existing users when sending an invitation
88-
config.invite_key = :email
8973

9074
# Flag that force a record to be valid before being actually invited
9175
# Default: false

entropi_social.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
1616
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
1717
s.test_files = Dir["test/**/*"]
1818

19-
s.add_dependency 'rails', '~> 3.2.0'
20-
s.add_dependency 'devise', '1.4.9'
21-
s.add_dependency "devise_invitable", "~> 0.6.0"
19+
s.add_dependency 'rails'
20+
s.add_dependency 'devise'
21+
#s.add_dependency "devise_invitable", "~> 0.6.0"
2222
s.add_dependency "carrierwave"
2323
s.add_dependency "squeel", "~> 0.9.5"
2424
s.add_development_dependency "sqlite3"

lib/entropi_social.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require "entropi_social/engine"
22
require 'devise'
3-
require 'devise_invitable'
43

54
require 'entropi_social/authorize'
65
require 'entropi_social/commentable'

lib/generators/entropi_social.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module EntropiSocial
44
module Generators
55
class Base < ::Rails::Generators::Base
66
def self.source_root
7-
@_entropi_social_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'alohomora', generator_name, 'templates'))
7+
@_entropi_social_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'entropi_social', generator_name, 'templates'))
88
end
99

1010
def self.banner
@@ -18,6 +18,10 @@ def add_gem(name, options = {})
1818
File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
1919
gem name, options unless gemfile_content.include? name
2020
end
21+
22+
def destination_path(path)
23+
File.join(destination_root, path)
24+
end
2125

2226
def print_usage
2327
self.class.help(Thor::Base.shell.new)

lib/generators/entropi_social/install/install_generator.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,44 @@
33

44
module EntropiSocial
55
module Generators
6-
class InstallGenerator < Base
6+
class InstallGenerator < EntropiSocial::Generators::Base
77
include ::Rails::Generators::Migration
88

99
def copy_initializers
1010

1111
end
1212

1313
def copy_configuration
14-
copy_file 'devise_invitable.en.yml', 'config/'
15-
copy_file 'devise.en.yml', 'config'
14+
copy_file 'devise_invitable.en.yml', 'config/devise_invitable.en.yml'
15+
copy_file 'devise.en.yml', 'config/devise.en.yml'
1616
end
1717

1818
def copy_models
19-
#copy_file 'user.rb', 'app/models/user.rb'
19+
copy_file 'user.rb', 'app/models/user.rb'
20+
copy_file 'profile.rb', 'app/models/profile.rb'
2021
end
2122

2223
def copy_migrations
23-
#migration_template 'create_identities.rb', 'db/migrate/create_identities.rb'
24+
migration_template '20111118193950_setup_entropi_social.rb', 'db/migrate/20111118193950_setup_entropi_social.rb'
2425
end
2526

2627
def add_gems
27-
#add_gem 'omniauth-identity'
28-
28+
add_gem 'omniauth-identity'
29+
add_gem 'squeel', '~> 0.9.5'
30+
add_gem 'bootstrapped','0.0.6'
31+
add_gem 'carrierwave'
32+
add_gem 'fog'
33+
add_gem 'rmagick', '2.12.2'
2934
end
3035

3136
def add_alohomora_routes
32-
#route %Q(match "/register", to: "identities#new", :as => "register")
37+
route %Q(mount EntropiSocial::Engine => '/', :as => 'entropi_social')
3338
end
39+
3440
private
3541

42+
43+
3644
def self.next_migration_number( dirname )
3745
next_migration_number = current_migration_number(dirname) + 1
3846
if ActiveRecord::Base.timestamped_migrations
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
class SetupEntropiSocial < ActiveRecord::Migration
2+
def up
3+
create_table :users do |t|
4+
t.string :username
5+
t.integer :invitation_limit, :default => 0
6+
t.database_authenticatable :null => false
7+
t.invitable
8+
t.recoverable
9+
t.rememberable
10+
t.trackable
11+
t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12+
t.timestamps
13+
end
14+
15+
# Setup Indexes for Users table
16+
add_index :users, :email, :unique => true
17+
add_index :users, :reset_password_token, :unique => true
18+
add_index :users, :unlock_token, :unique => true
19+
add_index :users, :username, :unique => true
20+
add_index :users, :invitation_token
21+
22+
create_table :profiles do |t|
23+
t.references :user
24+
t.string :first_name
25+
t.string :last_name
26+
t.date :birth_date
27+
t.integer :avatar_id
28+
t.text :about
29+
t.timestamps
30+
end
31+
32+
create_table :groups do |t|
33+
t.string :title
34+
t.integer :avatar_id
35+
t.references :profile
36+
t.references :groupable, :polymorphic => true
37+
t.timestamps
38+
end
39+
40+
create_table :friendships do |t|
41+
t.integer :inviter_id
42+
t.integer :invited_id
43+
t.string :status
44+
t.timestamps
45+
end
46+
47+
create_table :memberships do |t|
48+
t.integer :group_id
49+
t.integer :profile_id
50+
t.boolean :admin
51+
t.timestamps
52+
end
53+
54+
create_table :likes do |t|
55+
t.integer :user_id
56+
t.references :likable, :polymorphic => true
57+
t.timestamps
58+
end
59+
60+
add_index :likes, :likable_id
61+
add_index :likes, :likable_type
62+
63+
create_table :photos do |t|
64+
t.boolean :is_primary
65+
t.string :asset
66+
t.references :photoable, :polymorphic => true
67+
t.references :profile_id
68+
t.timestamps
69+
end
70+
71+
add_index :photos, :photoable_id
72+
add_index :photos, :photoable_type
73+
74+
create_table :comments do |t|
75+
t.text :comment
76+
t.references :commentable, :polymorphic => true
77+
t.references :profile
78+
t.string :role, :default => "comments"
79+
t.timestamps
80+
end
81+
82+
add_index :comments, :commentable_type
83+
add_index :comments, :commentable_id
84+
add_index :comments, :profile_id
85+
86+
create_table :accesses do |t|
87+
t.integer :group_id
88+
t.references :accessible, :polymorphic => true
89+
t.timestamps
90+
end
91+
92+
add_index :accesses, :group_id
93+
add_index :accesses, :accessible_id
94+
add_index :accesses, :accessible_type
95+
96+
create_table :albums do |t|
97+
t.string :name
98+
t.string :description
99+
t.references :profile
100+
t.timestamps
101+
end
102+
103+
create_table :sessions do |t|
104+
t.string :session_id, :null => false
105+
t.text :data
106+
t.timestamps
107+
end
108+
109+
add_index :sessions, :session_id
110+
add_index :sessions, :updated_at
111+
112+
# Create Default User
113+
profile = Profile.new
114+
profile.first_name = 'System'
115+
profile.last_name = 'Administrator'
116+
profile.birth_date = Time.now
117+
User.create!(:profile => profile, :username => 'timeline', :email => 'administrator@timeline.com', :password => 'password', :password_confirmation => "password")
118+
119+
end
120+
121+
def down
122+
123+
drop_table :users
124+
drop_table :profiles
125+
drop_table :groups
126+
drop_table :friendships
127+
drop_table :memberships
128+
drop_table :comments
129+
drop_table :likes
130+
drop_table :photos
131+
drop_table :accesses
132+
133+
end
134+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Profile < EntropiSocial::Profile
2+
3+
end

0 commit comments

Comments
 (0)