mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
user accout
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ package org.maxkey.web.contorller;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.authn.web.AuthorizationUtils;
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.entity.Accounts;
|
||||
@@ -115,7 +114,6 @@ public class AppListController {
|
||||
@ModelAttribute Accounts account,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
Accounts appUsers = new Accounts();
|
||||
|
||||
if (credential == Apps.CREDENTIALS.USER_DEFINED) {
|
||||
appUsers = accountsService.load(new Accounts(currentUser.getId(), account.getAppId()));
|
||||
if (appUsers == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,12 +18,13 @@
|
||||
package org.maxkey.web.contorller;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.crypto.Base32Utils;
|
||||
import org.maxkey.crypto.Base64Utils;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
@@ -31,7 +32,6 @@ import org.maxkey.password.onetimepwd.algorithm.OtpKeyUriFormat;
|
||||
import org.maxkey.password.onetimepwd.algorithm.OtpSecret;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.RQCodeUtils;
|
||||
import org.maxkey.web.image.ImageEndpoint;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -60,7 +60,8 @@ public class OneTimePasswordController {
|
||||
|
||||
@RequestMapping(value = {"/timebased"})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> timebased(@RequestParam String generate,@CurrentUser UserInfo currentUser) {
|
||||
public ResponseEntity<?> timebased(
|
||||
@RequestParam String generate,@CurrentUser UserInfo currentUser) {
|
||||
HashMap<String,Object >timebased =new HashMap<String,Object >();
|
||||
|
||||
generate(generate,currentUser);
|
||||
@@ -72,6 +73,8 @@ public class OneTimePasswordController {
|
||||
String otpauth = otpKeyUriFormat.format(currentUser.getUsername());
|
||||
byte[] byteSharedSecret = Base32Utils.decode(sharedSecret);
|
||||
String hexSharedSecret = Hex.encodeHexString(byteSharedSecret);
|
||||
BufferedImage bufferedImage = RQCodeUtils.write2BufferedImage(otpauth, "gif", 300, 300);
|
||||
String rqCode = Base64Utils.encodeImage(bufferedImage);
|
||||
|
||||
timebased.put("displayName", currentUser.getDisplayName());
|
||||
timebased.put("username", currentUser.getUsername());
|
||||
@@ -79,7 +82,7 @@ public class OneTimePasswordController {
|
||||
timebased.put("period", otpKeyUriFormat.getPeriod());
|
||||
timebased.put("sharedSecret", sharedSecret);
|
||||
timebased.put("hexSharedSecret", hexSharedSecret);
|
||||
timebased.put("rqCode", genRqCode(otpauth));
|
||||
timebased.put("rqCode", rqCode);
|
||||
return new Message<HashMap<String,Object >>(timebased).buildResponse();
|
||||
}
|
||||
|
||||
@@ -96,10 +99,5 @@ public class OneTimePasswordController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String genRqCode(String otpauth) {
|
||||
BufferedImage bufferedImage = RQCodeUtils.write2BufferedImage(otpauth, "gif", 300, 300);
|
||||
byte[] imageByte = ImageEndpoint.bufferedImage2Byte(bufferedImage);
|
||||
return "data:image/png;base64," + Base64.getEncoder().encodeToString(imageByte);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user