Advertisement
klimentmichal

autorizace

May 19th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. CUser u = StaticLocalDB.GetUserbyMail(userName.Value); //nalezeni uzivatele
  2.             if (FormsAuthentication.Authenticate(userName.Value, pwd.Value))//autentikace pro adminy z webconfigu
  3.             {
  4.                 u.LogIn();//nastaveni posledniho prihleseni
  5.                 FormsAuthentication.RedirectFromLoginPage(userName.Value, true);
  6.                 Response.Redirect("Admin/users.aspx");
  7.             }
  8.             else if (u != null && u.Pwd == pwd.Value)//autentikace uzivatelu registrovanych
  9.             {
  10.                 FormsAuthentication.SetAuthCookie(u.Email, true);//prihlaseni
  11.                 u.LogIn();//nastaveni posledniho prihleseni
  12.                 Response.Redirect("User/main.aspx");
  13.             }
  14.             else
  15.             {
  16.                 errorLogin.Text = "Špatná kombinace";
  17.             }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  public partial class IDCard : System.Web.UI.UserControl
  26.     {
  27.         CUser curent;
  28.         protected void Page_Load(object sender, EventArgs e)
  29.         {
  30.             //ziskani aktualniho uzivatele
  31.             curent = StaticLocalDB.GetUserbyMail(HttpContext.Current.User.Identity.Name);
  32.             if (curent != null)//pokud je prihlaseeny
  33.             {
  34.                 //ziskam udaje
  35.                 name.Text = curent.ToString();
  36.                 time.Text = curent.Loged.ToString();
  37.             }
  38.         }
  39.  
  40.         protected void LogOut_Click(object sender, EventArgs e)
  41.         {
  42.             //odhlaseni
  43.             FormsAuthentication.SignOut();
  44.             Response.Redirect("/Default.aspx");
  45.         }
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement