Make auth obligatory
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:grpc/grpc_web.dart';
|
||||
import 'package:softplayer_web/api/grpc/accounts.dart';
|
||||
import 'package:softplayer_web/components/menubar.dart';
|
||||
import 'package:softplayer_web/helpers/page_wrapper.dart';
|
||||
import 'package:softplayer_web/pages/about.dart';
|
||||
import 'package:softplayer_web/pages/catalog.dart';
|
||||
import 'package:softplayer_web/pages/home.dart';
|
||||
import 'package:softplayer_web/components/environments.dart';
|
||||
import 'package:softplayer_web/components/login_form.dart';
|
||||
|
||||
void main() async {
|
||||
const String backendURL = String.fromEnvironment(
|
||||
@@ -28,29 +27,13 @@ class MyApp extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Softplayer',
|
||||
routes: {
|
||||
'/': (context) => PageWrapper(
|
||||
appBar: MenuPanel(
|
||||
tab: TabName.home,
|
||||
accountsGrpc: accountsGrpc,
|
||||
),
|
||||
child: const HomePage(),
|
||||
),
|
||||
'/catalog': (context) => PageWrapper(
|
||||
appBar: MenuPanel(
|
||||
tab: TabName.catalog,
|
||||
accountsGrpc: accountsGrpc,
|
||||
),
|
||||
child: const CatalogPage(),
|
||||
),
|
||||
'/about': (context) => PageWrapper(
|
||||
appBar: MenuPanel(
|
||||
tab: TabName.about,
|
||||
accountsGrpc: accountsGrpc,
|
||||
),
|
||||
child: const AboutPage(),
|
||||
)
|
||||
},
|
||||
home: Scaffold(
|
||||
body: TestAlert(channel: channel),
|
||||
appBar: AppBar(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => print("1"),
|
||||
),
|
||||
),
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
useMaterial3: true,
|
||||
@@ -58,3 +41,29 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestAlert extends StatelessWidget {
|
||||
final GrpcWebClientChannel channel;
|
||||
TestAlert({super.key, required this.channel});
|
||||
late final AccountsGrpc accountsGrpc = AccountsGrpc(channel: channel);
|
||||
bool isSignedIn() {
|
||||
return window.localStorage.containsKey("token");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!isSignedIn()) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/login_background.jpg"),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: LoginForm(grpcChannel: channel),
|
||||
);
|
||||
} else {
|
||||
return EnvirnomentList(channel: channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user