public bool Autenticar(string usuario, string clave) { var id = usuario.ToLower(); using (var conexion = Conexion.Abrir()) { var db = new BaseDeDatos(conexion); var usr = db.Usuarios.FirstOrDefault(x => x.Id.ToLower() == id); if (usr == null) { return(false); } return(usr.Clave == Encriptador.CifrarClave(id, clave)); } }
public static void Configurar() { using (var conexion = Conexion.Abrir()) { var runner = new MigrationRunner( typeof(EsquemaConfig).Assembly, new RunnerContext(new ConsoleAnnouncer()), new SQLiteProcessor( conexion, new SQLiteGenerator(), new NullAnnouncer(), new ProcessorOptions(), new SQLiteDbFactory() ) ); runner.MigrateUp(); if (runner.CaughtExceptions != null) { foreach (var exception in runner.CaughtExceptions) { Trace.TraceError("Migration Error: {0}", exception); } } using (var db = new BaseDeDatos(conexion)) { var admin = db.Usuarios.FirstOrDefault(x => x.Id == "admin" && x.Clave == "admin"); if (admin == null) { return; } admin.Clave = Encriptador.CifrarClave(admin.Id, admin.Clave); db.SaveChanges(); } } }