Exemple #1
0
        public ActionResult Login(LoginModel model)
        {
            var result = new StandardJsonResult <dynamic>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var service = Ioc.GetService <IEnterpriseAccountService>();
                if (!service.CanLogin(model.UserName, model.Password))
                {
                    throw new KnownException("用户名/密码错误,登录失败");
                }
                BCSession.Login(model.UserName);

                result.Value = new
                {
                    UserID         = BCSession.User.UserID,
                    UserName       = BCSession.User.UserName,
                    EnterpriseID   = BCSession.User.EnterpriseID,
                    EnterpriseName = BCSession.User.EnterpriseName,
                    DepartmentID   = BCSession.User.DepartmentID,
                    HeadImage      = BCSession.User.Picture,
                    FunctionIDs    = BCSession.User.FunctionIDs.Where(n => n.StartsWith("Root.AppPermission")).ToArray(),
                    RoleIDs        = BCSession.User.RoleIDs,
                    Token          = BCSession.User.Token
                };
            });
            return(result);
        }
Exemple #2
0
        public ActionResult Login(LoginViewModel model)
        {
            var result = new StandardJsonResult();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var service = Ioc.GetService <IEnterpriseAccountService>();
                if (!service.CanLogin(model.Username, model.Password))
                {
                    throw new KnownException("用户名/密码错误,登录失败");
                }
                BCSession.Login(model.Username);
            });
            return(result);
        }
Exemple #3
0
        public ActionResult Login(LoginModel model)
        {
            var result = new StandardJsonResult <dynamic>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var service = Ioc.GetService <IEnterpriseAccountService>();
                if (!service.CanLogin(model.UserName, model.Password))
                {
                    throw new KnownException("用户名/密码错误,登录失败");
                }
                BCSession.Login(model.UserName);
                var appSyncService = Ioc.GetService <IAppSyncService>();
                var flag           = appSyncService.YesOrNo(model.LastTime);
                if (flag)
                {
                    appSyncService.ClearSyncState(model.UserName, model.DeviceID);
                    appSyncService.ChangeUserMessageQueueStatus(model.UserName, model.DeviceID, model.LastTime);
                }
                result.Value = new
                {
                    UserID         = BCSession.User.UserID,
                    UserName       = BCSession.User.UserName,
                    EnterpriseID   = BCSession.User.EnterpriseID,
                    EnterpriseName = BCSession.User.EnterpriseName,
                    DepartmentID   = BCSession.User.DepartmentID,
                    HeadImage      = BCSession.User.Picture,
                    FunctionIDs    = BCSession.User.FunctionIDs.Where(n => n.StartsWith("Root.AppPermission")).ToArray(),
                    RoleIDs        = BCSession.User.RoleIDs,
                    Token          = BCSession.User.Token,
                    Overdue        = flag
                };
            });
            return(result);
        }