public
Description: Slice based authentication based on restful_authentication (Not Maintained Here)
Homepage:
Clone URL: git://github.com/hassox/merbful_authentication.git
100644 171 lines (101 sloc) 5.479 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
MerbfulAuthentication
=====================
 
A slice for the Merb framework.
 
MerbfulAuthentication is an authentication framework for the Merb Web Framework.
 
Currently DataMapper is available and ActiveRecord is planned. Although it's easy to add your own.
 
MerbfulAuthentication provides your model with a mixin that gives your model all the required behavior
and links it to the controllers.
 
As an example. In your normal applications model directory create your user model.
 
class User
  include MerbfulAuthentication::Adapter::DataMapper
end
 
This will give the User class the required behavior and provide access to the class through
MerbfulAuthentication[:user] for other slice authors. To save key presses a handy constant is available
MA.
 
So using the MA constant you can declare your class like this
 
class Person
  include MA::Adapter::DataMapper
end
 
And in your custom slice, get access to the user class with MA[:user]
 
===Useful Helpers
 
The normal merbful_authentication helpers are available for your application, but also there is some consistent
helpers for other slice authors. Most notably is the controller helper
 
:current_ma_user also aliased as :current_person, or :current_user or whatever your user class name is.
 
=== Controllers
 
The controllers that drive MerbfulAuthentication are always named MA::Users, and MA::Sessions
 
These are then mapped to appropriately named routes.
 
=== Options
 
See notes after installation instructions
 
------------------------------------------------------------------------------
 
Instructions for installation:
 
=== Quick Install
# config/init.rb
dependency "merb-slices"
dependency "merbful_authentication"
 
# router
r.add_slice(:MerbfulAuthentication, "path/to/mount/at")
 
# Boot strap to your app
rake slices:merbful_authentication:install
 
 
=== Load the slice in your init.rb file
 
# add the slice as a regular dependency
 
dependency 'merbful_authentication'
 
# if needed, configure which slices to load and in which order
 
Merb::Plugins.config[:merb_slices] = { :queue => ["MerbfulAuthentication", ...] }
 
 
 
=== Configure Your Router
 
In config/router.rb you need to activate your brand new MerbfulAuthentication Slice. You can do this a number of ways.
 
The easiest way is like this:
 
r.add_slices
 
If you'd like to specify MerbfulAuthentication
 
r.add_slice(:MerbfulAuthentication)
 
By default this will mount the slice at /merbful_authentication. So your login url will be at
 
/merbful_authentication/login
 
If you'd like to specify a different mount point in your application (recommended) do it like this.
 
r.add_slice(:MerbfulAuthentication, 'authentcation')
 
Your login url will now be /authentication/login, your signup url will be at /authentication/users/new
 
If you'd like to set more options, I suggest you look up the merb-slices documentation.
 
 
 
=== Install your slice
 
You need to install the slice.
 
rake slices:merbful_authentication:install
 
=== Configuring your install.
 
If you don't have any configuration applied some simple defaults will be assumed. You configure your installation
by writing it to the config/slices.yml file
 
==== Routing options
:route_path_model: first choice for model route path. defaults to "users" (used to make single_model_path and plural_model_path)
:route_path_session: first choice for the sessions route path. Defaults to "sessions"
 
===== Named routes for the MA::Users resource
:user:
  :new: # ||= :"new_#{single_model_name}"
  :show: # ||= :"#{single_model_name}"
  :edit: # ||= :"edit_#{single_model_name}"
  :delete: # ||= :"delete_#{single_model_name}"
  :index: # ||= :"#{plural_model_path}"
  :activate: # ||= :"#{single_model_name}_activation"
  
A named route called :login, and one called :logout is also included.
 
 
=== Including activation emails for account verification
 
To include activation email to your uses use the
:use_activation: true option
 
To not use it either leave it out, or set it false like this
:use_activation: false
 
If this option is turned off, it will just automatically complete the relevant fields
to have an activated user. This way, if you decide later that you'd like to include activation
then the previously signed up users are already fully active and ready to fit into the new behavior :)
 
There is also the subjects that you can setup for your emails
 
:welcome_subject: # ||= "Welcome"
:activation_subject: # ||= "Please Activate Your Account"
 
------------------------------------------------------------------------------
 
You can put your application-level overrides in:
 
host-app/slices/merbful_authentication/app - controllers, models, views ...
 
Templates are located in this order:
 
1. host-app/slices/merbful_authentication/app/views/*
2. gems/merbful_authentication/app/views/*
3. host-app/app/views/*
 
You can use the host application's layout by configuring the
merbful_authentication slice in a before_app_loads block:
 
Merb::Slices.config[:merbful_authentication] = { :layout => :application }
 
By default :merbful_authentication is used. If you need to override
stylesheets or javascripts, just specify your own files in your layout
instead/in addition to the ones supplied (if any) in
host-app/public/slices/merbful_authentication.
 
In any case don't edit those files directly as they may be clobbered any time
rake merbful_authentication:install is run.
 
------------------------------------------------------------------------------