コード例 #1
0
        public string Login(AdminLoginModel adminLogin)
        {
            if (adminLogin == null)
            {
                return("Invalid Login info");
            }

            Admin loggedAdmin = _uow
                                .GetRepository <Admin>()
                                .GetAll()
                                .SingleOrDefault(a => a.AdminUsername == adminLogin.AdminUsername);

            if (loggedAdmin != null)
            {
                if (loggedAdmin.Password != adminLogin.Password)
                {
                    return(null);
                }
            }

            string jwtToken = tokenManager.CreateAdminAccessToken(new AdminModel
            {
                AdminId       = loggedAdmin.AdminId,
                AdminUsername = loggedAdmin.AdminUsername
            });

            return(jwtToken);
        }