File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 5252 "egi_checkin" : "social_core.backends.egi_checkin.EGICheckinOpenIdConnect" ,
5353 "oidc" : "social_core.backends.open_id_connect.OpenIdConnectAuth" ,
5454 "tapis" : "galaxy.authnz.tapis.TapisOAuth2" ,
55+ "weixin" : "galaxy.authnz.weixin.WeixinAuth2" ,
5556}
5657
5758BACKENDS_NAME = {
6667 "egi_checkin" : "egi-checkin" ,
6768 "oidc" : "oidc" ,
6869 "tapis" : "tapis" ,
70+ "weixin" : "weixin" ,
6971}
7072
7173AUTH_PIPELINE = (
Original file line number Diff line number Diff line change 1+ import re
2+ from social_core .backends .weixin import WeixinOAuth2
3+
4+ class WeixinAuth2 (WeixinOAuth2 ):
5+ name = 'weixin'
6+
7+ def user_data (self , access_token , * args , ** kwargs ):
8+ data = super ().user_data (access_token , * args , ** kwargs )
9+ if not data .get ('id_token' ):
10+ data ['id_token' ] = "dummy"
11+ return data
12+
13+ def get_user_id (self , details , response ):
14+ uid = response .get ('unionid' ) or response .get ('openid' )
15+ return uid .lower ()
16+
17+ def get_user_details (self , response ):
18+ data = super ().get_user_details (response )
19+ uid = self .get_user_id ({}, response )
20+ if not uid :
21+ return data
22+ username = re .sub (r'[^a-z0-9_]' , '_' , uid .lower ())
23+ data ['username' ] = username
24+ if not data .get ('email' ) and username :
25+ data ['email' ] = f"{ username } @dummy.com"
26+ return data
You can’t perform that action at this time.
0 commit comments