vForums Support > vForums :: Support :: > API: Email Verification Check (How To)
API: Email Verification Check (How To) - Posted By dog199200 (dog199200) on 26th Jan 10 at 12:29am
Ross,
How would you go about doing an account confirmation check for the API? The reason i am asking is because even if the account is not verified via email they can still login on the website, and i want it to that they can't login anywhere unless their account is email verified.
Re: API: Email Verification Check (How To) - Posted By Ross (admin) on 26th Jan 10 at 10:01am
Something along these lines
Obviously varying depending on how you have yours setup. I'd put it directly after you perform the login so that if they have not validated their e-mail you can straight away change their status to that of a guest.
$user_info = $vf -> login_user("user", "pass");
if(!is_array($user_info) || $user_info['validated_email'] == '0') {
$user_info = $vf -> logged_in = $vf -> api_user = $vf -> api_pass = false;
// + Any code here to tell the user they have to validate their e-mail
}
Re: API: Email Verification Check (How To) - Posted By dog199200 (dog199200) on 26th Jan 10 at 12:50pm
The only problem I am seeing is that it does it automatically, it doesn't wait will they hit the submit button on the login form, and if run it after they login it doesn't log them back out
i don't see how it work, maybe it work putting it into the API source?
Re: API: Email Verification Check (How To) - Posted By Ross (admin) on 26th Jan 10 at 1:42pm
$user_info = $vf -> login_user("user", "pass");
if(!is_array($user_info) || $user_info['validated_email'] == '0') {
if(is_array($user_info) && $user_info['validated_email'] == '0') {
// + Any code here to tell the user they have to validate their e-mail
}
$user_info = $vf -> logged_in = $vf -> api_user = $vf -> api_pass = false;
}
Try that. It's got an extra check to ensure they're tried to login.
Re: API: Email Verification Check (How To) - Posted By dog199200 (dog199200) on 26th Jan 10 at 2:11pm
No change other then it wont say anything to guest. Though the person of the account can login perfectly fine
Re: API: Email Verification Check (How To) - Posted By Ross (admin) on 26th Jan 10 at 11:13pm
Can you clarify? It's still not showing the message etc. to those without validated e-mails?
If I get chance I'll try setting it up on one of my API powered sites.
Re: API: Email Verification Check (How To) - Posted By dog199200 (dog199200) on 26th Jan 10 at 11:43pm
Well it shows the message when the login, but the idea is to prevent them from logging in and then displaying the message lol, I guess I could have it remove the cookie if verification returns false, and then echo out what i need to say.
Edit: nope that wont work either
and while i think about it, have you added a way to assign usergroups upon registration via the api? I know we talked about it before and you said it be something you'd look into, just not sure if its been added or is planning on being added.
Re: API: Email Verification Check (How To) - Posted By Ross (admin) on 27th Jan 10 at 10:50am
Can you post/pm the code you're using for the login / showing the message as well as which checks you're doing further down the page to see if the user is logged in?
Presuming the latest API version:
$vf -> request("add_to_group", Array("group" => 6));
That would add the currently logged in user to group6.
Re: API: Email Verification Check (How To) - Posted By dog199200 (dog199200) on 27th Jan 10 at 10:59am
I have all of my pages build together using the include function, so i'll zip of a few relevant pages and PM them to you.
hmm ok i'll try that and see if it works, but you did say logged in, and my registration system is still very buggy and some times logged the person in when the register and some times it doesn't
Edit: yep, as i though, no go
maybe i put it into my registration wrong, but i doubt it.