using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Login : System.Web.UI.Page
{
   /// <summary>
   /// Procedura obsługi dla przycisku logowania
   /// </summary>
protected void btnLogin_Click(object sender, EventArgs e)
{
   string user= txtUser.Text;
   string password = txtPassword.Text;

   //if (IsValidUser(user, password))
   if ( FormsAuthentication.Authenticate(user,password) )
      FormsAuthentication.RedirectFromLoginPage(user, true);
   else
      labError.Text = "Użytkownika nie odnaleziono. Proszę spróbować ponownie";
}

   /// <summary>
   /// Czy użytkownik jest prawidłowy?
   /// </summary>
   private bool IsValidUser(string user, string password)
   {
      if (user == "plato" && password == "abcdabcd")
         return true;
      else
         return false;
   }
}
