CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 HOWTO: only allow active user to login --resolved--

Print topic Send  topic

Author Message
pathans

Posts: 46
Posted: 05/01/2013, 6:00 PM

2 solutions provided below.
I tested both and both works. Please use what you like.

thanks guys


Original request

I have a field in employee table called active its yes or no.

is there anyway i can implement something in login.
so when user login it not only check username/password but also if the user is active.
View profile  Send private message
bannedone


Posts: 273
Posted: 05/01/2013, 6:07 PM

Sure

Do it in the on-click event for the login button.

In that event code you should see the login code.

just add some custom code there to do your check.

Have Fun
John
8-)

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
kawuat

Posts: 13
Posted: 05/01/2013, 7:57 PM

I had the same problem but didnt want to mess with CCS generated code so after hitting a few of the posts I worked out this approach.

the CCS login button on-click function returns 0 on failure and 1 on success so I added a custom on-click action to the button with the logic and checks I needed, in my case I have to create and load some user specific session variable and check to see if they had rights to login

So my on-click action looked like this

if Login_Button_DoLogin_OnClick == 1
... check active / inacative rights
if rights
... set custom session variables
... set Login_Button_DoLogin_OnClick == 1 (for completeness)
... set redirect (for completeness)
else
... custom error
... clear login fields
... set Login_Button_DoLogin_OnClick == 0
... call CCLogout (for completeness)
end if
:: REMOVED duplicate logic
end if
so far its worked out for me, not exactly elegant but so far I have not had problems and not needed to mess with CCS generated code
View profile  Send private message
bannedone


Posts: 273
Posted: 05/02/2013, 4:47 PM

Exactly....
That is the idea.. Just do a DLookup to get the parameter from the DB, do a check, then return with right values.

8-)
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
scarvello

Posts: 64
Posted: 05/02/2013, 8:17 PM

Simple build a Sql view like this :

" CREATE VIEW ACTIVE_USERS AS SELECT * FROM USER_TABLE WHERE ACTIVE=1".

Then use ACTIVE_USER as Datasource of login form.
View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/02/2013, 11:14 PM

guilty as charged for messin' around with common.php


$SQL = "SELECT iduser, accessid, password FROM users WHERE login=" . $db->ToSQL($login, ccsText) . " AND password=" . $db->ToSQL($password, ccsText) . " AND active= 'Y' ";

_________________
Central Coast, NSW, Australia.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.