Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public string Entrar(Account account)
        {
            var authRules = new AuthRules();

            if (authRules.Logar(account)) return Success(account);
            else return Error(authRules.MessageError);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        public void Update(Account account)
        {
            account.Ativa = true;
            account.GrupoPermissaoId = account.Permissao.Id;
            account.Tipo = AccountType.DEFAULT;

            this.Db.Update(account);
        }