File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,7 @@ export default function Header() {
39
39
{ session && (
40
40
< >
41
41
{ session . user . image && (
42
- < span
43
- style = { { backgroundImage : `url(${ session . user . image } )` } }
44
- className = { styles . avatar }
45
- />
42
+ < img src = { session . user . image } className = { styles . avatar } />
46
43
) }
47
44
< span className = { styles . signedInText } >
48
45
< small > Signed in as</ small >
Original file line number Diff line number Diff line change @@ -6,15 +6,29 @@ export default function AzureAD(options) {
6
6
id : "azure-ad" ,
7
7
name : "Azure Active Directory" ,
8
8
type : "oauth" ,
9
- authorization : `https://login.microsoftonline.com/${ tenant } /oauth2/v2.0/authorize?response_mode=query` ,
10
- token : `https://login.microsoftonline.com/${ tenant } /oauth2/v2.0/token` ,
11
- userinfo : "https://graph.microsoft.com/v1.0/me/" ,
12
- profile ( profile ) {
9
+ wellKnown : `https://login.microsoftonline.com/${ tenant } /v2.0/.well-known/openid-configuration` ,
10
+ authorization : {
11
+ params : {
12
+ scope : "User.Read" ,
13
+ } ,
14
+ } ,
15
+ async profile ( profile , tokens ) {
16
+ // https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0#examples
17
+ const profilePicture = await fetch (
18
+ "https://graph.microsoft.com/v1.0/me/photo/$value" ,
19
+ {
20
+ headers : {
21
+ Authorization : `Bearer ${ tokens . access_token } ` ,
22
+ } ,
23
+ }
24
+ )
25
+ const pictureBuffer = await profilePicture . arrayBuffer ( )
26
+ const pictureBase64 = Buffer . from ( pictureBuffer ) . toString ( "base64" )
13
27
return {
14
- id : profile . id ,
15
- name : profile . displayName ,
16
- email : profile . userPrincipalName ,
17
- image : null ,
28
+ id : profile . sub ,
29
+ name : profile . name ,
30
+ email : profile . email ,
31
+ image : `data:image/jpeg;base64, ${ pictureBase64 } ` ,
18
32
}
19
33
} ,
20
34
options,
You can’t perform that action at this time.
0 commit comments