Commit ab1d2106 authored by Liang Ding's avatar Liang Ding

🎨 解决特殊情况下用户绑定 GH 账号问题

parent 6c81abe2
......@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
* </ul>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.7, Mar 4, 2019
* @version 1.0.0.8, Mar 27, 2019
* @since 2.9.5
*/
@RequestProcessor
......@@ -202,6 +202,16 @@ public class OAuthProcessor {
LOGGER.log(Level.ERROR, "Register via oauth failed", e);
context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
} else {
user.put(UserExt.USER_GITHUB_ID, openId);
try {
userMgmtService.updateUser(user);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Update user GitHub id failed", e);
context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
......
......@@ -48,7 +48,7 @@ import javax.servlet.http.HttpServletResponse;
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/DASHU">DASHU</a>
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
* @version 1.1.0.17, Mar 20, 2019
* @version 1.1.0.18, Mar 27, 2019
* @since 0.4.0
*/
@Service
......@@ -156,7 +156,8 @@ public class UserMgmtService {
* "userName": "",
* "userRole": "",
* "userURL": "",
* "userB3Key": ""
* "userB3Key": "",
* "userGitHubId": "" // optional
* @throws ServiceException service exception
*/
public void updateUser(final JSONObject requestJSONObject) throws ServiceException {
......@@ -192,6 +193,11 @@ public class UserMgmtService {
final String userB3Key = requestJSONObject.optString(UserExt.USER_B3_KEY);
oldUser.put(UserExt.USER_B3_KEY, userB3Key);
final String userGitHubId = requestJSONObject.optString(UserExt.USER_GITHUB_ID);
if (StringUtils.isNotBlank(userGitHubId)) {
oldUser.put(UserExt.USER_GITHUB_ID, userGitHubId);
}
userRepository.update(oldUserId, oldUser);
transaction.commit();
} catch (final RepositoryException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment