Initial Commit

This commit is contained in:
Daniel Cortés
2019-12-12 04:06:08 -03:00
commit 3132ecc900
36 changed files with 3190 additions and 0 deletions

66
Universidad/login.aspx.cs Normal file
View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using Utils;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["username"] != null)
{
Response.Redirect("/index.aspx");
return;
}
}
protected void onLoginClick(object sender, EventArgs e)
{
if (Page.IsValid)
{
Entities entities = new Entities();
Usuario usuario = (from u in entities.Usuarios where u.nombre == username_box.Text select u).SingleOrDefault();
if (usuario == null)
{
error_message.Text = "El usuario o contraseña no son validos";
return;
}
if (!PasswordHash.Compare(password_box.Text, usuario.password))
{
error_message.Text = "El usuario o contraseña no son validos";
return;
}
Session["username"] = usuario.nombre;
Response.Redirect("/index.aspx");
}
}
protected void validateUsername(object sender, ServerValidateEventArgs e)
{
if (username_box.Text.Length > 15)
{
e.IsValid = false;
username_validator.Text = "El nombre de usuario es demasiado largo, maximo de 15 caracteres";
return;
}
e.IsValid = true;
}
protected void validatePassword(object sender, ServerValidateEventArgs e)
{
if (password_box.Text.Length > 15)
{
e.IsValid = false;
password_validator.Text = "La contraseña es demasiado larga, maximo de 15 caracteres";
return;
}
e.IsValid = true;
}
}