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

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"` RedirectURI string `json:"redirect_uri"`
GrantType string `json:"grant_type"` // authorization_code GrantType string `json:"grant_type"` // authorization_code
} }
type MicrosoftUserInfo struct { type MicrosoftUserInfo struct {
Sub string `json:"sub"` OdataContext string `json:"@odata.context"`
Name string `json:"name"` BusinessPhones []string `json:"businessPhones"`
PreferredUsername string `json:"preferred_username"` DisplayName string `json:"displayName"`
Email string `json:"email"` GivenName string `json:"givenName"`
Picture string `json:"picture"` JobTitle interface{} `json:"jobTitle"`
Groups interface{} `json:"groups"` 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 thirdPartyLoginStatus.Status = proto.ParameterError
} else { } else {
log.Printf("get %s user info:%v\n", state.Platform, userInfoResp) 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) HandleThirdPartyLoginStatusV2(state, &thirdPartyLoginStatus, &thirdPartyUserInfo)
thirdPartyLoginStatus.Status = proto.SuccessCode thirdPartyLoginStatus.Status = proto.SuccessCode
} }