Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
and where the store procedure is saved in the database and how i can find it.

What I have tried:

create procedure testlogin
@usrid varchar(50),@usrpass varchar(50)
as
declare @variable varchar(50)
select @variable= User_password from test_login where User_id=@usrid collate SQL_Latin1_General_CP1_CS_AS
if @variable=@usrpass
return 1
else
if @variable is null
return 0
else
return -1
Posted
Updated 12-Apr-16 23:25pm
Comments
F-ES Sitecore 13-Apr-16 5:07am    
No-one can answer this as we don't know how you are calling the SP. Google "read sql return value <insert name="" of="" database="" access="" technology="" here="">", but it'll probably be simpler if you change your SP to return a row rather than using return values. So if the password matches then

SELECT 1 as Success

otherwise

SELECT 0 as Success

as it's usually easily to deal with result sets than return values.

Don't.
Never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]
Do the checking in your PL code - and hash the password. You then retrieve the hash from the DB and compare it.
 
Share this answer
 
1. Please check security Concern when you are using plain text to save password.

2. You have to change your Procedure like:

create procedure testlogin
@usrid varchar(50),@usrpass varchar(50)
as
declare @variable int=0
select @variable=Count(User_ID) from test_login where User_id=@usrid and User_password=@usrpass collate SQL_Latin1_General_CP1_CS_AS
if @variable>0
begin
select 1
end
else if @variable=0
begin
select 0
end
else
begin
select -1
end


this procedure will return values Like Below:

1. If user found then it will return "1"
2. If user Not found then it will return "0"
3. else -1 (I don't know why you are using this status that's why I am adding this in else part)


you can get Procedure in
your Database/Programmability/Store Procedure
or you can use
sp_helptext "your Procedure name"

Ashish
 
Share this answer
 
v2
My answer would basically be same as OriginalGriff.

* When it comes to passwords, we should never store them in plain text.
* Nor they should be stored encrypted.
* They should always be stored as a hash value.
* Also, the password hashing process(at the time of registration) and checking the hash(at the time of login) should not be in the database procedures. It should always be in the application.
* If there are multiple applications that want to use the same db for authentication, either have the registration and login functionality pushed inside a class library or a Service.

For more details on why to store hashes and how to store and compare them, please see the below article.

A Beginner's Tutorial for Understanding and Implementing Password Hashing and Salting[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900