Login authorisation for different levels does not work
Hey again,
So this time I've got stuck with login stuff. I'm trying to set login based on the permissions level. In database i've got three fields: username, password and user_type. user_types are admin1 and admin2.
If I login with username and password for admin1 it goes well.
If login is with username and password for admin2 it goes to index page with no error message.
Following is the code:
<cfif IsDefined("FORM.username")>
<cfset MM_redirectLoginSuccess="../admin/index.cfm">
<cfset MM_redirectLoginFailed="index.cfm?failed=y">
<cfquery name="MM_rsUser" datasource="nodatabase">
SELECT username,password,user_type FROM users WHERE username=<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="45"> AND password=<cfqueryparam value="#Hash(FORM.password, "SHA")#" cfsqltype="cf_sql_clob" maxlength="64">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.username>
<cfset Session.MM_UserAuthorization=MM_rsUser.user_type[1]> WHAT IS THIS [1] ??????
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
Any thoughts where does it all go wrong?
cheers,
Simon
