Ejemplo n.º 1
0
        private UserBE SetContextAndAuthenticate(DreamMessage request, uint serviceid, bool autoCreateExternalUser, bool allowAnon, bool touchUser, out bool altPassword)
        {
            UserBE user = AuthBL.Authenticate(DreamContext.Current, request, serviceid, autoCreateExternalUser, allowAnon, out altPassword);

            // check if we should touch the user
            bool update = false;

            if (touchUser)
            {
                update = true;
            }
            else if (user.UserActive)
            {
                double?updateTimespan = DekiContext.Current.Instance.StatsUpdateUserOnAccess;
                if (updateTimespan.HasValue && (user.Touched.AddSeconds(updateTimespan.Value) <= DateTime.UtcNow))
                {
                    update = true;
                }
            }

            // update user's last logged time column
            if (update)
            {
                user = UserBL.UpdateUserTimestamp(user);
            }
            DekiContext.Current.User = user;

            // check that a user token is set (it might not be set if a user logs-in directly using HTTP authentication)
            if (!UserBL.IsAnonymous(user) && (DekiContext.Current.AuthToken == null))
            {
                DekiContext.Current.AuthToken = AuthBL.CreateAuthTokenForUser(user);
            }
            BanningBL.PerformBanCheckForCurrentUser();
            return(user);
        }
Ejemplo n.º 2
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            AuthBL authBL = new AuthBL();
            AuthBE authBE = new AuthBE(txtUser.Text.Trim(), txtPassword.Text.Trim());

            tries += 1;
            try {
                if (authBL.Authenticate(authBE) == true)
                {
                    frmMain  frmmain  = new frmMain();
                    frmLogin frmlogin = new frmLogin();
                    frmmain.Show();
                    this.Hide();
                    //frmlogin.Close();
                }
                else
                {
                    MessageBox.Show(this, "Error de autenticación ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            } catch (Exception ex) {
                if (tries == 3)
                {
                    MessageBox.Show(this, "Ya no tiene mas intentos", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
                MessageBox.Show(this, "Error de autenticación: " + ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public ApiResponse Post([FromBody] AuthVm authVm)
        {
            try
            {
                if (authBl.Authenticate(_uow, authVm))
                {
                    return(new ApiResponse()
                    {
                        Data = authService.GenerateToken(), Message = "Success", Status = 200
                    });
                }
                return(new ApiResponse()
                {
                    Data = null, Message = "unauthorized", Status = 200
                });
            }
            catch (System.Exception ex)
            {
                return(ApiResponse.Exception());

                throw;
            }
        }
Ejemplo n.º 4
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            AuthBL authBL = new AuthBL();
            AuthBE authBE = new AuthBE(txtUsuario.Text.Trim(), txtPassword.Text.Trim());

            tries += 1;
            try {
                if (authBL.Authenticate(authBE) == true)
                {
                    Response.Redirect("Overview.aspx");
                }
                else
                {
                    lblMensaje.Text = "Credenciales incorrectas, intente nuevamente.";
                }
            } catch (Exception ex) {
                if (tries == 3)
                {
                    Response.Redirect("Error.aspx");
                }
                lblMensaje.Text = ex.Message;
            }
        }