Whats up buudy check out the login controller

class LoginController < ApplicationController
def addprod
@category=Cattab1.find(:all)
@product=Prodtab.find(:all)
@i=0
@checkvalue=""
end

def login
@logincheck =Login.new
@prodcheck=Prodtab.new
if(session[:login_id])
Login.update(session[:login_id],:user_status=>“0”)
end
end

def login_create
@login = Login.new(params[:login])
if request.get?
session[:login_id] = nil
else
puts ‘logincretaeeeeeeeeeeeeeeeeeeeeeeeeee’
puts params[:login][:password]
params[:login][:password] =
Login.hashed_password(params[:login][:password])
puts params[:login][:password]
@logincheck =
Login.find_by_name_and_password(params[:login][:name],params[:login][:password])
if @logincheck == nil
#@logincheck.save
flash[:error] =“Name/Password not matching”
redirect_to :controller=>‘login’, :action=>‘login’ and
return
else
session[:login_id] = @logincheck.id
Login.update(@logincheck.id,:user_status=>“1”)
redirect_to :controller=>‘prodtabs’, :action=>‘index’
and return
end
end
end

def category3
puts ‘*category3
@categyid=request.raw_post
session[:category_id][email protected]_i
puts @categyid.to_i
@catlist=Cattab1.find_all_by_id(@categyid.to_i)
end

def category4
puts ‘*category4
@productid=request.raw_post
puts @productid.to_i
@prodlist=Prodtab.find_all_by_id(@productid.to_i)
end

def prod1
puts ‘prodids*’
puts params[:product_id]
puts ‘*vijay
@prodcheck1=params[:product_id]
@prodcheck=Prodtab.find_all_by_id(@prodcheck1)
@prodcheckcatid=Prodtab.find_all_by_cattab1_id(@prodcheck1)
@prodcheck.each do|p|
if p.cattab1_id==0
Prodtab.update(p.id ,:cattab1_id=>session[:category_id])
flash[:success] =“Product is assigned successfully”
else
flash[:error] ="#{p.pname} is already assigned"
redirect_to :controller=>‘login’, :action=>‘addprod’ and
return
end
#end
end
redirect_to:controller=>‘login’, :action=>‘addprod’
end
end

model

class Login < ActiveRecord::Base
validates_uniqueness_of :name

def self.hashed_password(password)
Digest::SHA1.hexdigest(password)
end
end

views

LOGIN FORM

<%= flash[:error] %>

<% form_tag({ :controller => "login", :action => "login_create"}, {:id=>"login", :name=>"login" ,:multipart => true}) do %>
      <tr><td><b>Login ID </b></td>
      <td><%= text_field 'login','name' %></td>
      </tr>

      <tr><td><b>  Password </b></td>
      <td><%= password_field 'login','password' %></td>
      </tr>

      <tr>
      <td></td><td align="left"> <input type="submit" value="Login"

onclick =“return compare1();”>

      <input type="reset" value="Clear"></td></tr>

      <% end %>

Whats up buudy? What code is this? It looks a bit gnarly…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs