-
-
Save mikecmpbll/d63b49493a12b0ef9310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppUser < ActiveRecord::Base | |
self.table_name = "AppUsers" | |
self.primary_key = 'UserID' | |
def self.authenticate(user_id, password) | |
if user = AppUser.where(UserID: user_id, Password: password) | |
unless user.nil? || user.empty? | |
return user | |
end | |
end | |
return nil | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login_attempt | |
authorized_user = AppUser.authenticate(params[:user_id],params[:user_password]) | |
@user = authorized_user.column_names | |
if authorized_user | |
redirect_to(:action => 'main') | |
else | |
flash[:notice] = "Invalid Username or Password" | |
flash[:color]= "invalid" | |
render "login" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppUser.authenticate('ADMIN', '') | |
AppUser Load (0.9ms) EXEC sp_executesql N'SELECT TOP (1) [AppUsers].* FROM [AppUsers] WHERE [AppUsers].[UserID] = N''ADMIN'' AND [AppUsers].[Password] = N'''' ORDER BY [AppUsers].[UserID] ASC' | |
=> #<AppUser UserID: "ADMIN", UserName: "Administrator", MenuGroup: "SYS_ADMIN", Password: "", DefaultStoreID: "1", FullRights: true, LastChanged: "2013-10-23 17:59:52", ChangedBy: "ADMIN", Email: "", Phone: "", Deleted: false, CashierID: "", HideCostPrice: false, WebLogin: false, CustomerID: "", DepID: "", NetworkID: ""> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment