Oct 13, 2013, 1:16 PM
Login throw IP (binding on IP)
Where i can find a good example of how to tie up login IP. I have default login form with two radio options for login: using cookie and using IP. Please send me where to find more information for this topic.
P.S.: I'm newbie for this project, but I wanna understand first how do this.
protected void btnLogin_Click(object sender, DirectEventArgs e) {
string userName = txtUsername.Text;
string password = txtPassword.Text;
//bool saveMe = chkSaveMe.Checked;
bool saveMe = radioCookie.Checked;
var user = Helper.AuthUser(userName, password);
if (user != null) {
Session["user"] = user;
if (!radioCookie.Checked && !radioIP.Checked) { //must be false
FormsAuthentication.SetAuthCookie(user.Id.ToString (CultureInfo.InvariantCulture), saveMe);
FormsAuthentication.RedirectFromLoginPage(user.Id. ToString(CultureInfo.InvariantCulture), saveMe);
Response.Redirect(Request.QueryString["ReturnUrl"] + "" == ""
? FormsAuthentication.DefaultUrl
: Request.QueryString["ReturnUrl"]);
}
if (radioCookie.Checked) { //must be true
FormsAuthentication.SetAuthCookie(user.Id.ToString (CultureInfo.InvariantCulture), saveMe);
FormsAuthentication.RedirectFromLoginPage(user.Id. ToString(CultureInfo.InvariantCulture), saveMe);
Response.Redirect(Request.QueryString["ReturnUrl"] + "" == ""
? FormsAuthentication.DefaultUrl
: Request.QueryString["ReturnUrl"]);
}
if (radioIP.Checked) { //must be true
/*
* Save IP to DB
*
*/
}
} else {
lblCheckError.Show();
X.AddScript("App.WindowLogin.el.unmask();");
}
}
P.S.: I'm newbie for this project, but I wanna understand first how do this.
protected void btnLogin_Click(object sender, DirectEventArgs e) {
string userName = txtUsername.Text;
string password = txtPassword.Text;
//bool saveMe = chkSaveMe.Checked;
bool saveMe = radioCookie.Checked;
var user = Helper.AuthUser(userName, password);
if (user != null) {
Session["user"] = user;
if (!radioCookie.Checked && !radioIP.Checked) { //must be false
FormsAuthentication.SetAuthCookie(user.Id.ToString (CultureInfo.InvariantCulture), saveMe);
FormsAuthentication.RedirectFromLoginPage(user.Id. ToString(CultureInfo.InvariantCulture), saveMe);
Response.Redirect(Request.QueryString["ReturnUrl"] + "" == ""
? FormsAuthentication.DefaultUrl
: Request.QueryString["ReturnUrl"]);
}
if (radioCookie.Checked) { //must be true
FormsAuthentication.SetAuthCookie(user.Id.ToString (CultureInfo.InvariantCulture), saveMe);
FormsAuthentication.RedirectFromLoginPage(user.Id. ToString(CultureInfo.InvariantCulture), saveMe);
Response.Redirect(Request.QueryString["ReturnUrl"] + "" == ""
? FormsAuthentication.DefaultUrl
: Request.QueryString["ReturnUrl"]);
}
if (radioIP.Checked) { //must be true
/*
* Save IP to DB
*
*/
}
} else {
lblCheckError.Show();
X.AddScript("App.WindowLogin.el.unmask();");
}
}