mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
auth UI and Api
This commit is contained in:
@ -1,66 +0,0 @@
|
||||
import 'package:syncrow_web/pages/auth/model/token.dart';
|
||||
|
||||
class UserModel {
|
||||
static String userUuidKey = 'userUuid';
|
||||
final String? uuid;
|
||||
final String? email;
|
||||
final String? name;
|
||||
final String? photoUrl;
|
||||
|
||||
final String? phoneNumber;
|
||||
|
||||
final bool? isEmailVerified;
|
||||
|
||||
final bool? isAgreementAccepted;
|
||||
|
||||
UserModel({
|
||||
required this.uuid,
|
||||
required this.email,
|
||||
required this.name,
|
||||
required this.photoUrl,
|
||||
required this.phoneNumber,
|
||||
required this.isEmailVerified,
|
||||
required this.isAgreementAccepted,
|
||||
});
|
||||
|
||||
factory UserModel.fromJson(Map<String, dynamic> json) {
|
||||
return UserModel(
|
||||
uuid: json['id'],
|
||||
email: json['email'],
|
||||
name: json['name'],
|
||||
photoUrl: json['photoUrl'],
|
||||
phoneNumber: json['phoneNumber'],
|
||||
isEmailVerified: json['isEmailVerified'],
|
||||
isAgreementAccepted: json['isAgreementAccepted'],
|
||||
);
|
||||
}
|
||||
|
||||
//uuid to json
|
||||
|
||||
//from token
|
||||
factory UserModel.fromToken(Token token) {
|
||||
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
||||
|
||||
return UserModel(
|
||||
uuid: tempJson['uuid'].toString(),
|
||||
email: tempJson['email'],
|
||||
name: null,
|
||||
photoUrl: null,
|
||||
phoneNumber: null,
|
||||
isEmailVerified: null,
|
||||
isAgreementAccepted: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': uuid,
|
||||
'email': email,
|
||||
'name': name,
|
||||
'photoUrl': photoUrl,
|
||||
'phoneNumber': phoneNumber,
|
||||
'isEmailVerified': isEmailVerified,
|
||||
'isAgreementAccepted': isAgreementAccepted,
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user