-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
365 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
part 'auth0_id_token.g.dart'; | ||
|
||
@JsonSerializable() | ||
class Auth0IdToken { | ||
Auth0IdToken({ | ||
required this.nickname, | ||
required this.name, | ||
required this.email, | ||
required this.picture, | ||
required this.updatedAt, | ||
required this.iss, | ||
required this.sub, // aka subject... the userId. | ||
required this.aud, | ||
required this.iat, | ||
required this.exp, | ||
this.authTime, | ||
}); | ||
|
||
final String nickname; | ||
final String name; | ||
final String picture; | ||
|
||
@JsonKey(name: 'updated_at') | ||
final String updatedAt; | ||
|
||
final String iss; | ||
|
||
// In OIDC, "sub" means "subject identifier", | ||
// which for our purposes is the user ID. | ||
// This getter makes it easier to understand. | ||
String get userId => sub; | ||
final String sub; | ||
|
||
final String aud; | ||
final String email; | ||
final int iat; | ||
final int exp; | ||
|
||
@JsonKey(name: 'auth_time') | ||
final int? authTime; // this might be null for the first time login | ||
|
||
factory Auth0IdToken.fromJson(Map<String, dynamic> json) => | ||
_$Auth0IdTokenFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$Auth0IdTokenToJson(this); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
part 'auth0_user.g.dart'; | ||
|
||
@JsonSerializable() | ||
class Auth0User { | ||
Auth0User({ | ||
required this.nickname, | ||
required this.name, | ||
required this.email, | ||
required this.picture, | ||
required this.updatedAt, | ||
required this.sub, | ||
}); | ||
final String nickname; | ||
final String name; | ||
final String picture; | ||
|
||
@JsonKey(name: 'updated_at') | ||
final String updatedAt; | ||
|
||
// userID getter to understand it easier | ||
String get id => sub; | ||
final String sub; | ||
|
||
final String email; | ||
|
||
factory Auth0User.fromJson(Map<String, dynamic> json) => | ||
_$Auth0UserFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$Auth0UserToJson(this); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.