OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/login/auth/login_performer.h" | 5 #include "chromeos/login/auth/login_performer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void LoginPerformer::OnPasswordChangeDetected() { | 99 void LoginPerformer::OnPasswordChangeDetected() { |
100 password_changed_ = true; | 100 password_changed_ = true; |
101 password_changed_callback_count_++; | 101 password_changed_callback_count_++; |
102 if (delegate_) { | 102 if (delegate_) { |
103 delegate_->OnPasswordChangeDetected(); | 103 delegate_->OnPasswordChangeDetected(); |
104 } else { | 104 } else { |
105 NOTREACHED(); | 105 NOTREACHED(); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 void LoginPerformer::OnChecked(const std::string& user_id, bool success) { | 109 void LoginPerformer::OnChecked(const user_manager::UserID& user_id, bool success
) { |
110 if (!delegate_) { | 110 if (!delegate_) { |
111 // Delegate is reset in case of successful offline login. | 111 // Delegate is reset in case of successful offline login. |
112 // See ExistingUserConstoller::OnAuthSuccess(). | 112 // See ExistingUserConstoller::OnAuthSuccess(). |
113 // Case when user has changed password and enters old password | 113 // Case when user has changed password and enters old password |
114 // does not block user from sign in yet. | 114 // does not block user from sign in yet. |
115 return; | 115 return; |
116 } | 116 } |
117 delegate_->OnOnlineChecked(user_id, success); | 117 delegate_->OnOnlineChecked(user_id, success); |
118 } | 118 } |
119 | 119 |
(...skipping 16 matching lines...) Expand all Loading... |
136 weak_factory_.GetWeakPtr(), | 136 weak_factory_.GetWeakPtr(), |
137 user_context_, | 137 user_context_, |
138 auth_mode))) { | 138 auth_mode))) { |
139 return; | 139 return; |
140 } | 140 } |
141 DoPerformLogin(user_context_, auth_mode); | 141 DoPerformLogin(user_context_, auth_mode); |
142 } | 142 } |
143 | 143 |
144 void LoginPerformer::DoPerformLogin(const UserContext& user_context, | 144 void LoginPerformer::DoPerformLogin(const UserContext& user_context, |
145 AuthorizationMode auth_mode) { | 145 AuthorizationMode auth_mode) { |
146 std::string email = gaia::CanonicalizeEmail(user_context.GetUserID()); | |
147 bool wildcard_match = false; | 146 bool wildcard_match = false; |
148 | 147 |
149 if (!IsUserWhitelisted(email, &wildcard_match)) { | 148 if (!IsUserWhitelisted(user_context.GetUserID(), &wildcard_match)) { |
150 NotifyWhitelistCheckFailure(); | 149 NotifyWhitelistCheckFailure(); |
151 return; | 150 return; |
152 } | 151 } |
153 | 152 |
154 if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK) | 153 if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK) |
155 SetupEasyUnlockUserFlow(user_context.GetUserID()); | 154 SetupEasyUnlockUserFlow(user_context.GetUserID()); |
156 | 155 |
157 switch (auth_mode_) { | 156 switch (auth_mode_) { |
158 case AUTH_MODE_EXTENSION: { | 157 case AUTH_MODE_EXTENSION: { |
159 RunOnlineWhitelistCheck( | 158 RunOnlineWhitelistCheck( |
160 email, wildcard_match, user_context.GetRefreshToken(), | 159 user_context.GetUserID(), wildcard_match, user_context.GetRefreshToken
(), |
161 base::Bind(&LoginPerformer::StartLoginCompletion, | 160 base::Bind(&LoginPerformer::StartLoginCompletion, |
162 weak_factory_.GetWeakPtr()), | 161 weak_factory_.GetWeakPtr()), |
163 base::Bind(&LoginPerformer::NotifyWhitelistCheckFailure, | 162 base::Bind(&LoginPerformer::NotifyWhitelistCheckFailure, |
164 weak_factory_.GetWeakPtr())); | 163 weak_factory_.GetWeakPtr())); |
165 break; | 164 break; |
166 } | 165 } |
167 case AUTH_MODE_INTERNAL: | 166 case AUTH_MODE_INTERNAL: |
168 StartAuthentication(); | 167 StartAuthentication(); |
169 break; | 168 break; |
170 } | 169 } |
171 } | 170 } |
172 | 171 |
173 void LoginPerformer::LoginAsSupervisedUser(const UserContext& user_context) { | 172 void LoginPerformer::LoginAsSupervisedUser(const UserContext& user_context) { |
174 DCHECK_EQ(chromeos::login::kSupervisedUserDomain, | 173 DCHECK_EQ(chromeos::login::kSupervisedUserDomain, |
175 gaia::ExtractDomainName(user_context.GetUserID())); | 174 gaia::ExtractDomainName(user_context.GetUserID().GetUserEmail())); |
176 | 175 |
177 user_context_ = user_context; | 176 user_context_ = user_context; |
178 user_context_.SetUserType(user_manager::USER_TYPE_SUPERVISED); | 177 user_context_.SetUserType(user_manager::USER_TYPE_SUPERVISED); |
179 | 178 |
180 if (RunTrustedCheck(base::Bind(&LoginPerformer::TrustedLoginAsSupervisedUser, | 179 if (RunTrustedCheck(base::Bind(&LoginPerformer::TrustedLoginAsSupervisedUser, |
181 weak_factory_.GetWeakPtr(), | 180 weak_factory_.GetWeakPtr(), |
182 user_context_))) { | 181 user_context_))) { |
183 return; | 182 return; |
184 } | 183 } |
185 TrustedLoginAsSupervisedUser(user_context_); | 184 TrustedLoginAsSupervisedUser(user_context_); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 user_context)); | 230 user_context)); |
232 } | 231 } |
233 | 232 |
234 void LoginPerformer::LoginOffTheRecord() { | 233 void LoginPerformer::LoginOffTheRecord() { |
235 EnsureAuthenticator(); | 234 EnsureAuthenticator(); |
236 task_runner_->PostTask( | 235 task_runner_->PostTask( |
237 FROM_HERE, | 236 FROM_HERE, |
238 base::Bind(&Authenticator::LoginOffTheRecord, authenticator_.get())); | 237 base::Bind(&Authenticator::LoginOffTheRecord, authenticator_.get())); |
239 } | 238 } |
240 | 239 |
241 void LoginPerformer::LoginAsKioskAccount(const std::string& app_user_id, | 240 void LoginPerformer::LoginAsKioskAccount(const user_manager::UserID& app_user_id
, |
242 bool use_guest_mount) { | 241 bool use_guest_mount) { |
243 EnsureAuthenticator(); | 242 EnsureAuthenticator(); |
244 task_runner_->PostTask(FROM_HERE, | 243 task_runner_->PostTask(FROM_HERE, |
245 base::Bind(&Authenticator::LoginAsKioskAccount, | 244 base::Bind(&Authenticator::LoginAsKioskAccount, |
246 authenticator_.get(), | 245 authenticator_.get(), |
247 app_user_id, | 246 app_user_id, |
248 use_guest_mount)); | 247 use_guest_mount)); |
249 } | 248 } |
250 | 249 |
251 void LoginPerformer::RecoverEncryptedData(const std::string& old_password) { | 250 void LoginPerformer::RecoverEncryptedData(const std::string& old_password) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } else { | 301 } else { |
303 NOTREACHED(); | 302 NOTREACHED(); |
304 } | 303 } |
305 user_context_.ClearSecrets(); | 304 user_context_.ClearSecrets(); |
306 } | 305 } |
307 | 306 |
308 void LoginPerformer::EnsureAuthenticator() { | 307 void LoginPerformer::EnsureAuthenticator() { |
309 authenticator_ = CreateAuthenticator(); | 308 authenticator_ = CreateAuthenticator(); |
310 } | 309 } |
311 } // namespace chromeos | 310 } // namespace chromeos |
OLD | NEW |