Exemplo n.º 1
0
        protected void LoginBtn_Click(object sender, EventArgs e)
        {
            //Prebereš username in password
            //Preveri, če je vse ok

            string cookie = Auth.Authenticate(Username.Text, Password.Value);

            if (cookie != null)
            {
                Userdata u = new Userdata();
                u.Username = Username.Text;
                u.Token    = cookie;

                //Daj mu cookie
                Session["userdata"] = u;
                Session["username"] = Username.Text;
                Session["pass"]     = Password.Value;
                Response.Redirect("Chat.aspx");
                //Redirect na chat
            }
            else
            {
                Error.Text = "Pri prijavi je prišlo do napake!!!";
            }
        }
Exemplo n.º 2
0
        protected void LogoutAdmin_Click(object sender, EventArgs e)
        {
            Session.Remove(CurrentUser.Text);

            Userdata u = Globals.active_users.FirstOrDefault(x => x.Username.Equals(CurrentUser.Text));

            Globals.active_users.Remove(u);

            Response.Redirect("Login.aspx");
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Userdata"] != null)
         {
             Userdata tmp_user = (Userdata)Session["userdata"];
             CurrentUser.Text = tmp_user.Username;
             if (!Globals.active_users.Contains(tmp_user))
             {
                 Globals.active_users.Add(tmp_user);
             }
         }
         else
         {
             Response.Redirect("Login.aspx");
         }
     }
     Refresh_Click(null, null);
 }
Exemplo n.º 4
0
        protected void AdminBtn_Click(object sender, EventArgs e)
        {
            WebRequest      request  = WebRequest.Create("http://servicechat1.azurewebsites.net/Service1.svc/Admin/" + Username.Text + "/" + Password.Value + "/");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            // Get the stream containing content returned by the server.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            reader.Close();
            dataStream.Close();
            response.Close();

            if ("true".Equals(responseFromServer))
            {
                string cookie = Auth.Authenticate(Username.Text, Password.Value);
                if (cookie != null)
                {
                    Userdata u = new Userdata();
                    u.Username = Username.Text;
                    u.Token    = cookie;

                    //Daj mu cookie
                    Session["userdata"] = u;
                }
                Session["username"] = Username.Text;
                Session["pass"]     = Password.Value;
                Response.Redirect("~/admin.aspx");
            }
            else
            {
                Error.Text = "Prijava v administratorske strani ni uspešna !!!";
            }
        }