daren771 (3/29/2006)
Here's my login.aspx
using
InstantASP.InstantForum;using
InstantASP.InstantForum.Data;using
InstantASP.Common;using
InstantASP.Common.UI;namespace
InstantForumAuthSampleProj{
public class Login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblStatus;
protected System.Web.UI.WebControls.TextBox txtUsername;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.Button butLogin;
protected System.Web.UI.WebControls.Button butLogout;
protected System.Web.UI.WebControls.CheckBox ckbRememberMe;
// page load event
private void Page_Load(object sender, System.EventArgs e)
{
// check to ensure this is not a postback
if (!Page.IsPostBack)
{
// are we currently authenticated?
if (System.Web.HttpContext .Current.Request.IsAuthenticated)
{
// if so attempt to create forum user object from generic principal
InstantASP.InstantForum.Components.User User = new InstantASP.InstantForum.Components.User (((InstantASP.Common.Authentication.GenericPrincipal )(System.Web.HttpContext .Current.User)));
// display login success
lblStatus.Text = ("Login Success for, "
+ (User.Username + "!" ));
}
}
}
// private method to handle click event from login button
private void butLogin_Click(object sender, System.EventArgs e)
{
// check to see if the username and password exists within the
// InstantASP_Users table. If we find a match then the user identity
// from the InstantASP_Users table is returned, else 0 is returned
Int32 UserID = InstantASP.Common.Authentication.Authentication .UserExists(txtUsername.Text, txtPassword.Text, InstantASP.Common.Enumerations.EnumLoginUsing .Username);
// did we find a user?
if ((UserID > 0))
{
// if so create an instance of the InstantASP.InstantForum.Components.User object
// from the user identity within the InstantASP_Users table
InstantASP.InstantForum.Components.User User = new InstantASP.InstantForum.Components.User (UserID);
// and log the InstantASP.InstantForum.Components.User object into the forums
User.Authenticate(ckbRememberMe.Checked, false );
// display login success
lblStatus.Text = ("Login Success for, "
+ (User.Username + "!" ));
}
else
{
// we did not find the users details
// update summary to display login failed information
lblStatus.Text = "Failed Login!" ;
}
}
// private method to handle click event from logout button
private void butLogout_Click(object sender, System.EventArgs e)
{
// check to ensure the user is already logged in
if (System.Web.HttpContext .Current.Request.IsAuthenticated)
{
// logout the current user
InstantASP.Common.Authentication.Authentication .Logout();
// update summary to display confirmation
lblStatus.Text = "Logout Success!" ;
}
else
{
// update summary to display confirmation
lblStatus.Text = "You are not logged in!" ;
}
}
}
}
InstantASP.InstantForum.Components.User User = new InstantASP.InstantForum.Components.User (UserID);
InstantASP.InstantForum.Components.User user = InstantASP.InstantForum.Business.User.SelectUser(System.Web.HttpContext.Current.User.Identity);
It was modified at InstantForum4.1.4 we will update our documentation.