Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
authentication service wip
  • Loading branch information
Casey Hillers committed Oct 28, 2019
commit 4647c9405c86a93cba97f75790bdcc825aced329
37 changes: 37 additions & 0 deletions app_flutter/lib/service/authentication.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart' show kReleaseMode;

/// Service class for interacting with authentication to Cocoon backend.
///
/// This service exists to have a universal location for all the authentication information.
abstract class AuthenticationService {
/// Creates a new [AuthenticationService] based on if Flutter app is in production.
///
/// Production uses the Google Sign In service.
/// Otherwise, use fake data that mimicks being authenticated.
factory AuthenticationService() {
if (kReleaseMode) {

}

return null;
}

/// Whether or not the application has been logged in to.
bool get isAuthenticated => _isAuthenticated;
bool _isAuthenticated = false;

/// The email of the current user logged in.
String get email => _email;
String _email;

/// The avatar url of the current user logged in.
String get avatarUrl => _avatarUrl;
String _avatarUrl;

/// Initiate the [GoogleSignIn] process.
Future<bool> signIn();
}
26 changes: 26 additions & 0 deletions app_flutter/lib/service/google_authentication.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:app_flutter/service/authentication.dart';
import 'package:google_sign_in_all/google_sign_in_all.dart';

class GoogleAuthenticationService extends AuthenticationService {
GoogleAuthenticationService({GoogleSignIn googleSignIn})
: _googleSignIn = googleSignIn ??
setupGoogleSignIn(
scopes: <String>[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe hoist these into private consts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
],
webClientId: 'github blocks me from putting you here :(',
),
super();

GoogleSignIn _googleSignIn;

AuthCredentials credentials;

GoogleAccount user;

@override
Future<bool> signIn() {
return null;
}
}