2021-12-30 20:04:00 +08:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
2021-12-17 18:24:32 +08:00
|
|
|
import 'package:angel3_migration/angel3_migration.dart';
|
|
|
|
|
import 'package:angel3_serialize/angel3_serialize.dart';
|
|
|
|
|
import 'package:angel3_orm/angel3_orm.dart';
|
|
|
|
|
import 'package:dde_gesture_manager_api/src/models/base_model.dart';
|
|
|
|
|
import 'package:optional/optional.dart';
|
2021-12-30 20:04:00 +08:00
|
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
|
|
2021-12-17 18:24:32 +08:00
|
|
|
part 'user.g.dart';
|
|
|
|
|
|
|
|
|
|
@serializable
|
|
|
|
|
@orm
|
|
|
|
|
abstract class _User extends BaseModel {
|
2021-12-30 20:04:00 +08:00
|
|
|
@Column(isNullable: false, indexType: IndexType.unique)
|
2021-12-17 18:24:32 +08:00
|
|
|
@SerializableField(isNullable: false)
|
|
|
|
|
String? get email;
|
|
|
|
|
|
2021-12-30 20:04:00 +08:00
|
|
|
@Column(isNullable: false, length: 32)
|
|
|
|
|
@SerializableField(isNullable: true, exclude: true)
|
2021-12-17 18:24:32 +08:00
|
|
|
String? get password;
|
|
|
|
|
|
2021-12-31 18:05:13 +08:00
|
|
|
@Column(isNullable: false)
|
|
|
|
|
@SerializableField(defaultValue: false)
|
|
|
|
|
bool? get blocked;
|
|
|
|
|
|
2021-12-30 20:04:00 +08:00
|
|
|
String secret(String salt) => base64.encode(Hmac(sha256, salt.codeUnits).convert((password ?? '').codeUnits).bytes);
|
|
|
|
|
}
|