Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Unified Diff: pkg/appengine/lib/src/api_impl/users_impl.dart

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/appengine/lib/src/api_impl/users_impl.dart
diff --git a/pkg/appengine/lib/src/api_impl/users_impl.dart b/pkg/appengine/lib/src/api_impl/users_impl.dart
new file mode 100644
index 0000000000000000000000000000000000000000..012e12c73e314276bf19965d49993a03a45a508e
--- /dev/null
+++ b/pkg/appengine/lib/src/api_impl/users_impl.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library users_impl;
+
+import 'dart:async';
+
+import 'package:appengine/api/users.dart';
+
+import '../protobuf_api/user_service.dart';
+import '../protobuf_api/rpc/rpc_service.dart';
+import '../protobuf_api/internal/user_service.pb.dart' as pb;
+import '../server/http_wrapper.dart';
+
+class UserRpcImpl extends UserService {
+ static String _HTTP_HEADER_AUTH_DOMAIN = 'x-appengine-auth-domain';
+ static String _HTTP_HEADER_USER_EMAIL = 'x-appengine-user-email';
+ static String _HTTP_HEADER_USER_ID = 'x-appengine-user-id';
+ static String _HTTP_HEADER_USER_IS_ADMIN = 'x-appengine-user-is-admin';
+
+ final UserServiceClientRPCStub _clientRPCStub;
+ User _currentUser;
+
+ UserRpcImpl(
+ RPCService rpcService, String ticket, AppengineHttpRequest request)
+ : _clientRPCStub = new UserServiceClientRPCStub(rpcService, ticket) {
+ var userEmail = request.headers.value(_HTTP_HEADER_USER_EMAIL);
+ var userId = request.headers.value(_HTTP_HEADER_USER_ID);
+ var userIsAdmin = request.headers.value(_HTTP_HEADER_USER_IS_ADMIN) == '1';
+ var authDomain = request.headers.value(_HTTP_HEADER_AUTH_DOMAIN);
+
+ if (userEmail != null && !userEmail.isEmpty) {
+ _currentUser = new User(
+ authDomain: authDomain,
+ email: userEmail, id: userId,
+ isAdmin: userIsAdmin);
+ }
+ }
+
+ User get currentUser => _currentUser;
+
+ Future<String> createLoginUrl(String destination) {
+ var request = new pb.CreateLoginURLRequest();
+ request.destinationUrl = destination;
+ return _clientRPCStub.CreateLoginURL(request)
+ .then((response) => response.loginUrl);
+ }
+
+ Future<String> createLogoutUrl(String destination) {
+ var request = new pb.CreateLogoutURLRequest();
+ request.destinationUrl = destination;
+ return _clientRPCStub.CreateLogoutURL(request)
+ .then((response) => response.logoutUrl);
+ }
+}
« no previous file with comments | « pkg/appengine/lib/src/api_impl/remote_api_impl.dart ('k') | pkg/appengine/lib/src/app_engine_request_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698