Marcio Garcia

Software Empowerment²

Screencast - restful_authentication

with 3 comments


restful_authentication - Screencast (pt-br) from Marcio Garcia on Vimeo.

Instalação do restful_authentication

URL do plugin:

http://svn.techno-weenie.net/projects/plugins/restful_authentication/

./scrpt/plugin source http://svn.techno-weenie.net/projects/plugins/restful_authentication/
 
./script/plugin install restful_authentication

Criação dos controllers e model padrão
./script/generate authenticated user sessions

Alterações de código

routes.rb
#novas rotas....
map.signup '/', :controller => 'sessions', :action => 'new'
map.signup '/signup', :controller => 'users', :action => 'new'
map.login  '/login',  :controller => 'sessions', :action => 'new'
map.logout '/logout', :controller => 'sessions', :action => 'destroy'

app/views/layouts/application.html.erb
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <%= stylesheet_link_tag 'scaffold' %>
</head>
<body bgcolor="#1471B7">
<center>
<p>&nbsp;</p>
<table width="90%"  bgcolor="#FFFFFF">
	<tr>
		<td align="center">
		<%= yield%>			
		</td>
	</tr>
</table>
</center>
</body>
</html>





app/controllers/application.rb
include AuthenticatedSystem

app/controllers/sessions_controller.rb
def new
  #alterado....................
  flash[:notice] = "Usuario logado!" if logged_in?
  flash[:notice] = "Usuario NÃO logado!" unless logged_in?
end

app/controllers/users_controller.rb
#alterado......................
before_filter :authentication
def authentication
  redirect_back_or_default('/') unless logged_in?
end

Código fonte

rademo.zip

Written by Marcio

November 7th, 2008 at 12:13 am

3 Responses to 'Screencast - restful_authentication'

Subscribe to comments with RSS or TrackBack to 'Screencast - restful_authentication'.

  1. Oi Marcio, com o Rails 2.2 acho boa idéia utilizar o restful-authentication-i18n :D :

    http://github.com/dcrec1/restful-authentication-i18n/tree/master

    Diego Carrion

    7 Nov 08 at 4:37 pm

  2. Brother libera o .mov do video pra gente, o do vimeo ficou baixo e pequeno. :P

    Junio Vitorino

    8 Nov 08 at 9:12 pm

  3. [...] comments Recentemente publiquei um post com screencast a respeito de autenticação com restful_authentication, o Kadu Adu me questionou como fazer [...]

Leave a Reply