Search in sources :

Example 81 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class UserInfoController method forwardChangePassword.

@RequestMapping(value = { "/forwardChangePassword/{id}" })
public ModelAndView forwardChangePassword(@PathVariable("id") String id) {
    ModelAndView modelAndView = new ModelAndView("/userinfo/changePassword");
    UserInfo userInfo = userInfoService.get(id);
    modelAndView.addObject("model", userInfo);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class AccountsController method generate.

@ResponseBody
@RequestMapping(value = "/generate")
public String generate(@ModelAttribute("appAccounts") Accounts appAccounts) {
    AccountsStrategy accountsStrategy = accountsStrategyService.get(appAccounts.getStrategyId());
    UserInfo userInfo = userInfoService.get(appAccounts.getUserId());
    return accountsService.generateAccount(userInfo, accountsStrategy);
}
Also used : AccountsStrategy(org.maxkey.entity.AccountsStrategy) UserInfo(org.maxkey.entity.UserInfo) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 83 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class LoginSessionController method deleteUsersById.

@ResponseBody
@RequestMapping(value = "/terminate")
public Message deleteUsersById(@RequestParam("id") String ids) {
    _logger.debug(ids);
    boolean isTerminated = false;
    try {
        String currentUserSessionId = "";
        if (WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID) != null) {
            currentUserSessionId = WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID).toString();
        }
        for (String sessionId : StringUtils.string2List(ids, ",")) {
            _logger.trace("terminate session Id {} ", sessionId);
            if (currentUserSessionId.contains(sessionId)) {
                // skip current session
                continue;
            }
            UserInfo userInfo = WebContext.getUserInfo();
            String lastLogoffTime = DateUtils.formatDateTime(new Date());
            loginRepository.updateLastLogoff(userInfo);
            loginHistoryRepository.logoff(lastLogoffTime, sessionId);
            onlineTicketServices.remove("OT-" + sessionId);
        }
        isTerminated = true;
    } catch (Exception e) {
        _logger.debug("terminate Exception .", e);
    }
    if (isTerminated) {
        return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS), MessageType.success);
    } else {
        return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_ERROR), MessageType.error);
    }
}
Also used : ConstsOperateMessage(org.maxkey.constants.ConstsOperateMessage) Message(org.maxkey.web.message.Message) UserInfo(org.maxkey.entity.UserInfo) Date(java.util.Date) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 84 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class HistoryLogsAdapter method postHandle.

// after the handler is executed
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    // 读取session中message
    Message message = WebContext.getMessage();
    if (message != null) {
        if (message.getMessageScope() == MessageScope.DB || message.getMessageScope() == MessageScope.DB_CLIENT) {
            // 判断message类型
            // 取得当前用户信息
            UserInfo userInfo = WebContext.getUserInfo();
            // 创建日志记录
            HistoryLogs historyLog = new HistoryLogs(message.getServiceName(), message.getCode(), message.getMessage(), JsonUtils.object2Json(message.getMessageObject()), message.getMessageType().toString(), message.getOperateType().toString(), userInfo == null ? null : userInfo.getId(), userInfo == null ? null : userInfo.getUsername(), "");
            historyLog.setInstId(userInfo.getInstId());
            _logger.debug("insert db logs content : " + historyLog);
            // 日志插入数据库
            historySystemLogsService.insert(historyLog);
            if (message.getMessageScope() == MessageScope.DB) {
                // message类型仅插入数据库
                // 清除message
                WebContext.clearMessage();
            }
        }
    }
}
Also used : HistoryLogs(org.maxkey.entity.HistoryLogs) Message(org.maxkey.web.message.Message) UserInfo(org.maxkey.entity.UserInfo)

Example 85 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class FeishuUsersService method buildUserInfo.

public UserInfo buildUserInfo(FeishuUsers user) {
    UserInfo userInfo = new UserInfo();
    // 账号
    userInfo.setUsername(user.getUser_id());
    // 名字
    userInfo.setNickName(user.getNickname());
    // 名字
    userInfo.setDisplayName(user.getName());
    // 手机
    userInfo.setMobile(user.getMobile());
    userInfo.setEmail(user.getEmail());
    userInfo.setGender(user.getGender());
    userInfo.setEmployeeNumber(user.getEmployee_no());
    // 工作电话
    userInfo.setWorkPhoneNumber(user.getMobile());
    userInfo.setDepartmentId(user.getDepartment_ids()[0] + "");
    // 职务
    userInfo.setJobTitle(user.getJob_title());
    // 工作地点
    userInfo.setWorkAddressFormatted(user.getWork_station());
    // 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。
    if (user.getStatus().isIs_activated()) {
        userInfo.setStatus(ConstsStatus.ACTIVE);
    } else {
        userInfo.setStatus(ConstsStatus.INACTIVE);
    }
    userInfo.setInstId(this.synchronizer.getInstId());
    return userInfo;
}
Also used : UserInfo(org.maxkey.entity.UserInfo)

Aggregations

UserInfo (org.maxkey.entity.UserInfo)85 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)42 ModelAndView (org.springframework.web.servlet.ModelAndView)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)15 Message (org.maxkey.web.message.Message)8 Date (java.util.Date)7 HashMap (java.util.HashMap)7 Operation (io.swagger.v3.oas.annotations.Operation)6 ConstsOperateMessage (org.maxkey.constants.ConstsOperateMessage)6 Accounts (org.maxkey.entity.Accounts)6 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)6 SigninPrincipal (org.maxkey.authn.SigninPrincipal)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ServiceResponseBuilder (org.maxkey.authz.cas.endpoint.response.ServiceResponseBuilder)4 AbstractAuthorizeAdapter (org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter)4 SynchroRelated (org.maxkey.entity.SynchroRelated)4 NamingException (javax.naming.NamingException)3 ProxyServiceResponseBuilder (org.maxkey.authz.cas.endpoint.response.ProxyServiceResponseBuilder)3 Ticket (org.maxkey.authz.cas.endpoint.ticket.Ticket)3 Apps (org.maxkey.entity.apps.Apps)3