Jump to content
  • 0

3 User login app with redirects and timout feature HELP!!!!!


Mustafa007

Question

Hello everybody!!

I'm trying to put together an application that allows different users to log into my system and depending on their credentials, they will be brought to a different interface.

I would like to have three types of users - Admin, Staff, and Guest.

Some requirements:

1. When a user logs out of the app, they will be brought to the main sign in page.

2. Only Active users can login

3. After logout and time out they should go back to main login page

Please help. Thank you much in advance!!!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

You need to have one Yes/No field for each user group and also one Yes/No field for Active in your authentication table. Then you should create a view to filter the data for each user group.

Guest_view filter by Active field when equals to checked.
Admin_View filter by Active field when equals to checked and Admin is checked.
Staff_View filter by Active field when equals to checked and Staff is checked.

Create three folders for each user group and use the corresponding view as the authentication source of the folder. To redirect user to the main page after logout or time out:

In all authentication wizards select custom and add Header/Footer to Configure Fields screen:
In Header:

<div id="cb_login_module" style="display:none">

In Footer:

</div>
<script type='text/javascript'>
var cb_login_page="URL OF MAIN LOGIN PAGE";
if(!document.getElementById('cb_login_box') && document.getElementById('cb_login_module')){
                window.location= cb_login_page;
} else {
                document.getElementById("cb_login_module").style.display = "" ;
}
</script>

In User group folder create an HTML DataPage to redirect users based on the user type to different web pages using this script:
 

<script>
var v_admin = "[@authfield:Admin]" ;
var v_contributor = "[@authfield:Staff]" ;

/* if admin send to admin portal */
if (v_admin.toLowerCase() == "yes" || v_admin.toLowerCase() == "y") {
window.location = "URLâ€;

/* if Staff send to Staff portal */
} else if (v_contributor.toLowerCase() == "yes" || v_contributor.toLowerCase() == "y") {
window.location = "URL" ;

/* if Guest send to Guest portal */	
} else {
window.location = "URLâ€;
}
</script>

When you deploy this HTML DataPage on your web page you need to wrap the deploy code

<div id='cb_login_box'>
Caspio Deploy Code
</div>

This method is being used in knowledge base ready-made app. You can also request for this app and see the way they programmed it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...