LICENSE.md
This commit is contained in:
@@ -9,7 +9,6 @@ import 'cookie_client_stub.dart'
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class APIProvider{
|
||||
@@ -54,27 +53,32 @@ class APIProvider{
|
||||
String password,
|
||||
]) async {
|
||||
assert(
|
||||
(username != null && password != null) ||
|
||||
(_accessToken != null && _refreshToken != null)
|
||||
(username != null && password != null)
|
||||
);
|
||||
|
||||
QueryResult response = await _client.query(
|
||||
QueryOptions(
|
||||
document: LoginQuery().document,
|
||||
variables: {
|
||||
"user": "admin",
|
||||
"password": "admin"
|
||||
"user": username,
|
||||
"password": password
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
final loginResponse = Login$Query.fromJson(response.data);
|
||||
print(loginResponse);
|
||||
|
||||
return loginResponse.login;
|
||||
}
|
||||
|
||||
void logout() {
|
||||
Future<Me$Query$User> me() async {
|
||||
QueryResult response = await _client.query(
|
||||
QueryOptions(
|
||||
document: MeQuery().document,
|
||||
)
|
||||
);
|
||||
|
||||
final meResponse = Me$Query.fromJson(response.data);
|
||||
return meResponse.me;
|
||||
}
|
||||
|
||||
Future<String> mediaItems([
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:imagini/core/imagini_application.dart';
|
||||
import 'package:imagini/api/imagini_api_repository.dart';
|
||||
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class SplashBloc{
|
||||
@@ -27,7 +26,9 @@ class SplashBloc{
|
||||
|
||||
initializeLogin(){
|
||||
ImaginiAPIRepository imaginiAPI = _application.imaginiAPI;
|
||||
_loginController.addStream(imaginiAPI.login("admin", "admin2"));
|
||||
|
||||
// TODO: This should actually attempt to load the existing Tokens, not login
|
||||
_loginController.addStream(imaginiAPI.login("admin", "admin"));
|
||||
|
||||
// imaginiAPI.login("admin", "admin1").listen((LoginResponse lr) {
|
||||
// });
|
||||
|
||||
@@ -114,6 +114,62 @@ class CreateMediaItem$Mutation with EquatableMixin {
|
||||
Map<String, dynamic> toJson() => _$CreateMediaItem$MutationToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Me$Query$User with EquatableMixin {
|
||||
Me$Query$User();
|
||||
|
||||
factory Me$Query$User.fromJson(Map<String, dynamic> json) =>
|
||||
_$Me$Query$UserFromJson(json);
|
||||
|
||||
String id;
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
DateTime updatedAt;
|
||||
|
||||
String email;
|
||||
|
||||
String username;
|
||||
|
||||
String firstName;
|
||||
|
||||
String lastName;
|
||||
|
||||
@JsonKey(unknownEnumValue: Role.artemisUnknown)
|
||||
Role role;
|
||||
|
||||
@JsonKey(unknownEnumValue: AuthType.artemisUnknown)
|
||||
AuthType authType;
|
||||
|
||||
@override
|
||||
List<Object> get props => [
|
||||
id,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
email,
|
||||
username,
|
||||
firstName,
|
||||
lastName,
|
||||
role,
|
||||
authType
|
||||
];
|
||||
Map<String, dynamic> toJson() => _$Me$Query$UserToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Me$Query with EquatableMixin {
|
||||
Me$Query();
|
||||
|
||||
factory Me$Query.fromJson(Map<String, dynamic> json) =>
|
||||
_$Me$QueryFromJson(json);
|
||||
|
||||
Me$Query$User me;
|
||||
|
||||
@override
|
||||
List<Object> get props => [me];
|
||||
Map<String, dynamic> toJson() => _$Me$QueryToJson(this);
|
||||
}
|
||||
|
||||
enum AuthResult {
|
||||
@JsonValue('Success')
|
||||
success,
|
||||
@@ -122,6 +178,22 @@ enum AuthResult {
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
enum Role {
|
||||
@JsonValue('Admin')
|
||||
admin,
|
||||
@JsonValue('User')
|
||||
user,
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
enum AuthType {
|
||||
@JsonValue('Local')
|
||||
local,
|
||||
@JsonValue('LDAP')
|
||||
ldap,
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginArguments extends JsonSerializable with EquatableMixin {
|
||||
@@ -352,3 +424,87 @@ class CreateMediaItemMutation
|
||||
CreateMediaItem$Mutation parse(Map<String, dynamic> json) =>
|
||||
CreateMediaItem$Mutation.fromJson(json);
|
||||
}
|
||||
|
||||
class MeQuery extends GraphQLQuery<Me$Query, JsonSerializable> {
|
||||
MeQuery();
|
||||
|
||||
@override
|
||||
final DocumentNode document = DocumentNode(definitions: [
|
||||
OperationDefinitionNode(
|
||||
type: OperationType.query,
|
||||
name: NameNode(value: 'me'),
|
||||
variableDefinitions: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'me'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'id'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'createdAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'updatedAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'email'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'username'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'firstName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'lastName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'role'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'authType'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null)
|
||||
]))
|
||||
]))
|
||||
]);
|
||||
|
||||
@override
|
||||
final String operationName = 'me';
|
||||
|
||||
@override
|
||||
List<Object> get props => [document, operationName];
|
||||
@override
|
||||
Me$Query parse(Map<String, dynamic> json) => Me$Query.fromJson(json);
|
||||
}
|
||||
|
||||
@@ -137,6 +137,61 @@ Map<String, dynamic> _$CreateMediaItem$MutationToJson(
|
||||
'createMediaItem': instance.createMediaItem?.toJson(),
|
||||
};
|
||||
|
||||
Me$Query$User _$Me$Query$UserFromJson(Map<String, dynamic> json) {
|
||||
return Me$Query$User()
|
||||
..id = json['id'] as String
|
||||
..createdAt = json['createdAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['createdAt'] as String)
|
||||
..updatedAt = json['updatedAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updatedAt'] as String)
|
||||
..email = json['email'] as String
|
||||
..username = json['username'] as String
|
||||
..firstName = json['firstName'] as String
|
||||
..lastName = json['lastName'] as String
|
||||
..role = _$enumDecodeNullable(_$RoleEnumMap, json['role'],
|
||||
unknownValue: Role.artemisUnknown)
|
||||
..authType = _$enumDecodeNullable(_$AuthTypeEnumMap, json['authType'],
|
||||
unknownValue: AuthType.artemisUnknown);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Me$Query$UserToJson(Me$Query$User instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'createdAt': instance.createdAt?.toIso8601String(),
|
||||
'updatedAt': instance.updatedAt?.toIso8601String(),
|
||||
'email': instance.email,
|
||||
'username': instance.username,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'role': _$RoleEnumMap[instance.role],
|
||||
'authType': _$AuthTypeEnumMap[instance.authType],
|
||||
};
|
||||
|
||||
const _$RoleEnumMap = {
|
||||
Role.admin: 'Admin',
|
||||
Role.user: 'User',
|
||||
Role.artemisUnknown: 'ARTEMIS_UNKNOWN',
|
||||
};
|
||||
|
||||
const _$AuthTypeEnumMap = {
|
||||
AuthType.local: 'Local',
|
||||
AuthType.ldap: 'LDAP',
|
||||
AuthType.artemisUnknown: 'ARTEMIS_UNKNOWN',
|
||||
};
|
||||
|
||||
Me$Query _$Me$QueryFromJson(Map<String, dynamic> json) {
|
||||
return Me$Query()
|
||||
..me = json['me'] == null
|
||||
? null
|
||||
: Me$Query$User.fromJson(json['me'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Me$QueryToJson(Me$Query instance) => <String, dynamic>{
|
||||
'me': instance.me?.toJson(),
|
||||
};
|
||||
|
||||
LoginArguments _$LoginArgumentsFromJson(Map<String, dynamic> json) {
|
||||
return LoginArguments(
|
||||
user: json['user'] as String,
|
||||
|
||||
@@ -59,7 +59,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
if(null == bloc){
|
||||
bloc = SplashBloc(AppProvider.getApplication(context));
|
||||
bloc.loginResult.listen((Login$Query$AuthResponse lr) {
|
||||
if (lr.result != AuthResult.success) {
|
||||
if (lr.result == AuthResult.success) {
|
||||
AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn);
|
||||
} else {
|
||||
AppProvider.getRouter(context).navigateTo(context, "/Login", transition: TransitionType.fadeIn);
|
||||
|
||||
Reference in New Issue
Block a user