Permalink
Browse files

authlogic working with sql

  • Loading branch information...
stellard committed Dec 16, 2010
1 parent 1561d8f commit 99993e44ea5fbd2b3e3a333591bc33d066f73ec5
Showing with 34 additions and 12 deletions.
  1. +5 −5 app/controllers/users_controller.rb
  2. +27 −7 app/views/layouts/application.html.erb
  3. +2 −0 app/views/users/_form.html.erb
@@ -13,7 +13,7 @@ def index
# GET /users/1
# GET /users/1.xml
def show
- @user = User.find(params[:id])
+ @user = current_user
respond_to do |format|
format.html # show.html.erb
@@ -34,7 +34,7 @@ def new
# GET /users/1/edit
def edit
- @user = User.find(params[:id])
+ @user = current_user
end
# POST /users
@@ -56,7 +56,7 @@ def create
# PUT /users/1
# PUT /users/1.xml
def update
- @user = User.find(params[:id])
+ @user = current_user
respond_to do |format|
if @user.update_attributes(params[:user])
@@ -72,11 +72,11 @@ def update
# DELETE /users/1
# DELETE /users/1.xml
def destroy
- @user = User.find(params[:id])
+ @user = current_user
@user.destroy
respond_to do |format|
- format.html { redirect_to(users_url) }
+ format.html { redirect_to(user_session_path, :method => :delete) }
format.xml { head :ok }
end
end
@@ -1,14 +1,34 @@
-<!DOCTYPE html>
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Oauth</title>
- <%= stylesheet_link_tag :all %>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title><%= controller.controller_name %>: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
<%= javascript_include_tag :defaults %>
- <%= csrf_meta_tag %>
</head>
<body>
-<%= yield %>
+<span style="float: right; text-align: right;"><%= link_to "Source code", "http://github.com/binarylogic/authlogic_example" %> | <%= link_to "Setup tutorial", "http://www.binarylogic.com/2008/11/3/tutorial-authlogic-basic-setup" %> | <%= link_to "Password reset tutorial", "http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic" %><br />
+<%= link_to "OpenID tutorial", "http://www.binarylogic.com/2008/11/21/tutorial-using-openid-with-authlogic" %> | <%= link_to "Authlogic Repo", "http://github.com/binarylogic/authlogic" %> | <%= link_to "Authlogic Doc", "http://authlogic.rubyforge.org/" %></span>
+<h1>Authlogic Example App</h1>
+<%= pluralize User.logged_in.count, "user" %> currently logged in<br /> <!-- This based on last_request_at, if they were active < 10 minutes they are logged in -->
+<br />
+<br />
+
+
+<% if !current_user %>
+ <%= link_to "Register", new_account_path %> |
+ <%= link_to "Log In", new_user_session_path %> |
+<% else %>
+ <%= link_to "My Account", account_path %> |
+ <%= link_to "Logout", user_session_path, :method => :delete, :confirm => "Are you sure you want to logout?" %>
+<% end %>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
</body>
-</html>
+</html>
@@ -1,5 +1,7 @@
<%= form.label :login %><br />
<%= form.text_field :login %><br />
+<%= form.label :email %><br />
+<%= form.text_field :email %><br />
<br />
<%= form.label :password, form.object.new_record? ? nil : "Change password" %><br />
<%= form.password_field :password %><br />

0 comments on commit 99993e4

Please sign in to comment.