remymumoh

Untitled

Nov 10th, 2020 (edited)
811
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class _SignInState extends State<SignIn> {
  2.  
  3.   @override
  4.   void initState() {
  5.     super.initState();
  6.     MsalMobile.create('assets/auth_config.json', authority).then((client) {
  7.       setState(() {
  8.         msal = client;
  9.       });
  10.       refreshSignedInStatus();
  11.     });
  12.   }
  13.  
  14.   /// Updates the signed in state
  15.   refreshSignedInStatus() {
  16.     msal.getSignedIn().then((loggedIn) {
  17.       print('refreshing');
  18.       setState(() async {
  19.         isSignedIn = loggedIn;
  20.         dynamic currentAccount = await handleGetAccount();
  21.         if(isSignedIn) {
  22.           Navigator.of(context).pushReplacement(
  23.  
  24.             MaterialPageRoute(
  25.               builder: (context) => NavScreen(
  26.                 currentUser : currentAccount,
  27.               ),
  28.             ),
  29.           );
  30.         }
  31.       });
  32.     });
  33.   }
  34.  
  35.   /// Gets the current and prior accounts.
  36.   Future <dynamic> handleGetAccount() async {
  37.     await msal.getAccount().then((result) {
  38.       if (result.currentAccount != null) {
  39.         return result.currentAccount.username;
  40.       } else {
  41.         print('no account found');
  42.         return null;
  43.       }
  44.     }).catchError((exception) {
  45.       if (exception is MsalMobileException) {
  46.         logMsalMobileError(exception);
  47.       } else {
  48.         print('exception occurred');
  49.         return null;
  50.       }
  51.     });
  52.   }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×