添加微软第三方登录,未测试

This commit is contained in:
junleea 2025-05-18 10:57:49 +08:00
parent cc41bec298
commit 43cadd7f42
2 changed files with 14 additions and 7 deletions

View File

@ -358,11 +358,18 @@ type MicrosoftOAuthRequest struct {
RedirectURI string `json:"redirect_uri"`
GrantType string `json:"grant_type"` // authorization_code
}
type MicrosoftUserInfo struct {
Sub string `json:"sub"`
Name string `json:"name"`
PreferredUsername string `json:"preferred_username"`
Email string `json:"email"`
Picture string `json:"picture"`
Groups interface{} `json:"groups"`
OdataContext string `json:"@odata.context"`
BusinessPhones []string `json:"businessPhones"`
DisplayName string `json:"displayName"`
GivenName string `json:"givenName"`
JobTitle interface{} `json:"jobTitle"`
Mail interface{} `json:"mail"`
MobilePhone interface{} `json:"mobilePhone"`
OfficeLocation interface{} `json:"officeLocation"`
PreferredLanguage string `json:"preferredLanguage"`
Surname string `json:"surname"`
UserPrincipalName string `json:"userPrincipalName"`
ID string `json:"id"`
}

View File

@ -729,7 +729,7 @@ func DoMicroSoftCallBack(state *proto.ThirdPartyLoginState, code string) {
thirdPartyLoginStatus.Status = proto.ParameterError
} else {
log.Printf("get %s user info:%v\n", state.Platform, userInfoResp)
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfoResp.Sub, Name: userInfoResp.Name, Avatar: userInfoResp.Picture, Email: userInfoResp.Email}
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfoResp.ID, Name: userInfoResp.DisplayName, Avatar: "", Email: ""}
HandleThirdPartyLoginStatusV2(state, &thirdPartyLoginStatus, &thirdPartyUserInfo)
thirdPartyLoginStatus.Status = proto.SuccessCode
}