🥅 Better unauthorized exceptions
This commit is contained in:
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exceptions/unauthorized.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
@ -89,7 +90,7 @@ class AttachmentProvider extends GetConnect {
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient(
|
||||
'uc',
|
||||
@ -131,7 +132,7 @@ class AttachmentProvider extends GetConnect {
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('uc');
|
||||
|
||||
@ -169,7 +170,7 @@ class AttachmentProvider extends GetConnect {
|
||||
String cid,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient(
|
||||
'uc',
|
||||
@ -193,7 +194,7 @@ class AttachmentProvider extends GetConnect {
|
||||
bool isMature = false,
|
||||
}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('files');
|
||||
|
||||
@ -211,7 +212,7 @@ class AttachmentProvider extends GetConnect {
|
||||
|
||||
Future<Response> deleteAttachment(int id) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('files');
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exceptions/unauthorized.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/widgets/account/relative_select.dart';
|
||||
@ -16,7 +17,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<void> refreshAvailableChannel() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
isLoading.value = true;
|
||||
final resp = await listAvailableChannel();
|
||||
@ -29,7 +30,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<Response> getChannel(String alias, {String realm = 'global'}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -44,7 +45,7 @@ class ChannelProvider extends GetxController {
|
||||
Future<Response> getMyChannelProfile(String alias,
|
||||
{String realm = 'global'}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -59,7 +60,7 @@ class ChannelProvider extends GetxController {
|
||||
Future<Response?> getChannelOngoingCall(String alias,
|
||||
{String realm = 'global'}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -75,7 +76,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<Response> listChannel({String scope = 'global'}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -89,7 +90,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<Response> listAvailableChannel({String realm = 'global'}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -103,7 +104,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<Response> createChannel(String scope, dynamic payload) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -118,7 +119,7 @@ class ChannelProvider extends GetxController {
|
||||
Future<Response?> createDirectChannel(
|
||||
BuildContext context, String scope) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final related = await showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
@ -149,7 +150,7 @@ class ChannelProvider extends GetxController {
|
||||
|
||||
Future<Response> updateChannel(String scope, int id, dynamic payload) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exceptions/unauthorized.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
@ -36,7 +37,7 @@ class PostProvider extends GetConnect {
|
||||
|
||||
Future<Response> listDraft(int page) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw UnauthorizedException();
|
||||
|
||||
final queries = [
|
||||
'take=${10}',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exceptions/unauthorized.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
|
||||
@ -8,7 +9,7 @@ class RealmProvider extends GetxController {
|
||||
|
||||
Future<void> refreshAvailableRealms() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw const UnauthorizedException();
|
||||
|
||||
isLoading.value = true;
|
||||
final resp = await listAvailableRealm();
|
||||
@ -21,7 +22,7 @@ class RealmProvider extends GetxController {
|
||||
|
||||
Future<Response> getRealm(String alias) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw const UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
@ -35,7 +36,7 @@ class RealmProvider extends GetxController {
|
||||
|
||||
Future<Response> listAvailableRealm() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
if (auth.isAuthorized.isFalse) throw const UnauthorizedException();
|
||||
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
|
Reference in New Issue
Block a user