update auth service to handle user creation errors and expand consent request scopes
This commit is contained in:
@ -48,9 +48,6 @@ func (a authService) getUserByPhoneNumber(ctx context.Context, phoneNumber strin
|
||||
|
||||
func (a authService) getOrCreateUser(ctx context.Context, phoneNumber string) (*userDomain.User, error) {
|
||||
user, err := a.userService.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if user == nil {
|
||||
user, err = a.userService.CreateUser(ctx, phoneNumber)
|
||||
if err != nil {
|
||||
@ -91,7 +88,7 @@ func (a authService) AcceptConsent(ctx context.Context, phoneNumber string, chal
|
||||
return "", err
|
||||
}
|
||||
request := hydraApi.AcceptConsentRequest{}
|
||||
request.SetGrantScope([]string{"openid"})
|
||||
request.SetGrantScope([]string{"openid", "offline", "offline_access"})
|
||||
request.SetRemember(true)
|
||||
request.SetRememberFor(3600)
|
||||
|
||||
|
||||
18
tips
Normal file
18
tips
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
http://oauth2.logidex.ru/oauth2/auth?client_id=172eb7e2-3b9f-4d4a-907a-d008cc15f08c&response_type=code&scope=openid+offline+offline_access&redirect_uri=http://crm.logidex.ru/auth/callback&state=random123
|
||||
http://crm.logidex.ru/auth/callback?code=ory_ac_a_OklDs30yo44y_VUXM_nqktKvOShDN6ZHnyhQ0Chlc.u-iLZyzy0I6pmTuF5apE-rualitEHPmbZJkPNw1q34s&scope=openid&state=random123
|
||||
|
||||
|
||||
|
||||
/ $ hydra create oauth2-client \
|
||||
> --endpoint http://127.0.0.1:4445/ \
|
||||
> --grant-type authorization_code \
|
||||
> --grant-type refresh_token \
|
||||
> --response-type code \
|
||||
> --scope openid \
|
||||
> --scope offline \
|
||||
> --scope offline_access \
|
||||
> --redirect-uri "http://crm.logidex.ru/auth/callback" \
|
||||
> --format json
|
||||
{"client_id":"172eb7e2-3b9f-4d4a-907a-d008cc15f08c","client_name":"","client_secret":"l3t21k~LpUV1ztKYh_pLgmgsD1","client_secret_expires_at":0,"client_uri":"","created_at":"2025-10-26T23:00:45Z","grant_types":["authorization_code","refresh_token"],"jwks":{},"logo_uri":"","metadata":{},"owner":"","policy_uri":"","redirect_uris":["http://crm.logidex.ru/auth/callback"],"registration_access_token":"ory_at_27xocFJj0JJ9HJS95rWZ-9AwXDY32m7CemhVrq1LRtQ.kauzcPMwUzsjsB82p4Kvbh83UKWdKK4Jz_vL3trt1NM","registration_client_uri":"http://oauth2.logidex.ru/oauth2/register/","request_object_signing_alg":"RS256","response_types":["code"],"scope":"openid offline offline_access","skip_consent":false,"skip_logout_consent":false,"subject_type":"public","token_endpoint_auth_method":"client_secret_basic","tos_uri":"","updated_at":"2025-10-26T23:00:45.167057Z","userinfo_signed_response_alg":"none"}
|
||||
Reference in New Issue
Block a user