public bool Logar(Account account) { var accountRepositorio = new AccountRepositorio(); var accountCurrent = accountRepositorio.Fetch(account.Username); //usuario nao existe if (accountCurrent == null) { this.MessageError = "USUARIO_SENHA_INCORRETA"; return false; } //senha errada if (accountCurrent.Password != account.Password) { this.MessageError = "USUARIO_SENHA_INCORRETA"; return false; } //usuario cancelado if (!accountCurrent.Ativa) { this.MessageError = "USUARIO_CANCELADO"; return false; } var sessionRepositorio = new SessionRepositorio(); var session = new Session(); session.Account = accountCurrent; sessionRepositorio.Add(session); FormsAuthentication.SetAuthCookie(session.Presence, true); return true; }
public string Entrar(Account account) { var authRules = new AuthRules(); if (authRules.Logar(account)) return Success(account); else return Error(authRules.MessageError); }
public void Add(Account account) { account.Ativa = true; account.UsuarioId = account.Usuario.Id; account.GrupoPermissaoId = account.Permissao.Id; account.Tipo = AccountType.DEFAULT; this.Db.Insert(account); }
public bool ExistUsername(Account account) { return this.Db.ExecuteScalar<int>("SELECT COUNT(*) FROM Account WHERE Username = @0 AND Account.Id != @1", account.Username, account.Id) == 0 ? false : true; }
public void Update(Account account) { account.Ativa = true; account.GrupoPermissaoId = account.Permissao.Id; account.Tipo = AccountType.DEFAULT; this.Db.Update(account); }