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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library users_impl;
6
7 import 'dart:async';
8
9 import 'package:appengine/api/users.dart';
10
11 import '../protobuf_api/user_service.dart';
12 import '../protobuf_api/rpc/rpc_service.dart';
13 import '../protobuf_api/internal/user_service.pb.dart' as pb;
14 import '../server/http_wrapper.dart';
15
16 class UserRpcImpl extends UserService {
17 static String _HTTP_HEADER_AUTH_DOMAIN = 'x-appengine-auth-domain';
18 static String _HTTP_HEADER_USER_EMAIL = 'x-appengine-user-email';
19 static String _HTTP_HEADER_USER_ID = 'x-appengine-user-id';
20 static String _HTTP_HEADER_USER_IS_ADMIN = 'x-appengine-user-is-admin';
21
22 final UserServiceClientRPCStub _clientRPCStub;
23 User _currentUser;
24
25 UserRpcImpl(
26 RPCService rpcService, String ticket, AppengineHttpRequest request)
27 : _clientRPCStub = new UserServiceClientRPCStub(rpcService, ticket) {
28 var userEmail = request.headers.value(_HTTP_HEADER_USER_EMAIL);
29 var userId = request.headers.value(_HTTP_HEADER_USER_ID);
30 var userIsAdmin = request.headers.value(_HTTP_HEADER_USER_IS_ADMIN) == '1';
31 var authDomain = request.headers.value(_HTTP_HEADER_AUTH_DOMAIN);
32
33 if (userEmail != null && !userEmail.isEmpty) {
34 _currentUser = new User(
35 authDomain: authDomain,
36 email: userEmail, id: userId,
37 isAdmin: userIsAdmin);
38 }
39 }
40
41 User get currentUser => _currentUser;
42
43 Future<String> createLoginUrl(String destination) {
44 var request = new pb.CreateLoginURLRequest();
45 request.destinationUrl = destination;
46 return _clientRPCStub.CreateLoginURL(request)
47 .then((response) => response.loginUrl);
48 }
49
50 Future<String> createLogoutUrl(String destination) {
51 var request = new pb.CreateLogoutURLRequest();
52 request.destinationUrl = destination;
53 return _clientRPCStub.CreateLogoutURL(request)
54 .then((response) => response.logoutUrl);
55 }
56 }
OLDNEW
« 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