added a vuln for broken auth and session mgmt, issue #2
This commit is contained in:
@@ -7,13 +7,20 @@ class SessionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
||||||
|
begin
|
||||||
user = User.authenticate(params[:email], params[:password])
|
user = User.authenticate(params[:email], params[:password])
|
||||||
|
rescue Exception => e
|
||||||
|
end
|
||||||
|
|
||||||
if user
|
if user
|
||||||
session[:id] = user.id if User.where(:id => user.id).exists?
|
session[:id] = user.id if User.where(:id => user.id).exists?
|
||||||
redirect_to home_dashboard_index_path
|
redirect_to home_dashboard_index_path
|
||||||
else
|
else
|
||||||
|
flash[:error] = e.message
|
||||||
render "new"
|
render "new"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
+7
-1
@@ -13,8 +13,14 @@ class User < ActiveRecord::Base
|
|||||||
auth = nil
|
auth = nil
|
||||||
user = find_by_email(email)
|
user = find_by_email(email)
|
||||||
# I heard something about hashing, dunno, why bother really. Nobody will get access to my stuff!
|
# I heard something about hashing, dunno, why bother really. Nobody will get access to my stuff!
|
||||||
if user && user.password == password
|
if user
|
||||||
|
if user.password == password
|
||||||
auth = user
|
auth = user
|
||||||
|
else
|
||||||
|
raise "Incorrect Password!"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise "#{email} doesn't exist!"
|
||||||
end
|
end
|
||||||
return auth
|
return auth
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="dashboard-wrapper">
|
<div class="dashboard-wrapper">
|
||||||
|
<%= render "layouts/shared/messages" %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<% flash.each do |name, msg| %>
|
||||||
|
<% if name == :error %>
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<a class="close" data-dismiss="alert" href="#">×</a>
|
||||||
|
<%= content_tag :div, msg, :id => "flash_notice" %>
|
||||||
|
</div>
|
||||||
|
<% elsif name == :success %>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<a class="close" data-dismiss="alert" href="#">×</a>
|
||||||
|
<%= content_tag :div, msg, :id => "flash_notice" %>
|
||||||
|
</div>
|
||||||
|
<% elsif name == :info %>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<a class="close" data-dismiss="alert" href="#">×</a>
|
||||||
|
<%= content_tag :div, msg, :id => "flash_notice" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
Reference in New Issue
Block a user