public void OnLogin(SynkContext context) { var username = context.loadVarFromRequest("username"); var password = context.loadVarFromRequest("password"); var dbName = context.config.GetFieldValue("database"); var cond = Condition.Equal("username", username); var user = context.database.FetchEntity <User>(cond); string hash = null; if (user != null && user.exists) { hash = user.GetFieldValue("hash"); } if (context.database.failed) { context.warning = "Database error!"; context.PushTemplate("auth/default"); } else if (user != null && user.exists && (string.IsNullOrEmpty(hash) || this.checkPassword(password, hash))) { if (context.config.GetFieldBool("instanced")) { dbName = user.GetFieldValue("database"); } context.LogIn(user.id, dbName); ShowDefaultPage(context); return; } else { if (user.exists) { context.warning = "Dados de login invalidos!"; } else { context.warning = "Utilizador não existente!"; } context.PushTemplate("auth/default"); } context.Render(); }
private void FetchPage(SynkContext context) { this.entityID = -1; //this.filter = context.loadVar("filter", null); var pageVal = context.loadVarFromRequest("page", "0"); int.TryParse(pageVal, out this.currentPage); }