1 // Copyright (c) .NET Foundation. All rights reserved. 2 // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 4 using System.Collections.Generic; 5 using System.Threading; 6 using System.Threading.Tasks; 7 8 namespace Microsoft.AspNetCore.Identity 9 { 10 /// <summary> 11 /// Provides an abstraction for storing information that maps external login information provided 12 /// by Microsoft Account, Facebook etc. to a user account. 13 /// </summary> 14 /// <typeparam name="TUser">The type that represents a user.</typeparam> 15 public interface IUserLoginStore<TUser> : IUserStore<TUser> where TUser : class 16 { 17 /// <summary> 18 /// Adds an external <see cref="UserLoginInfo"/> to the specified <paramref name="user"/>. 19 /// </summary> 20 /// <param name="user">The user to add the login to.</param> 21 /// <param name="login">The external <see cref="UserLoginInfo"/> to add to the specified <paramref name="user"/>.</param> 22 /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> 23 /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns> AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken)24 Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken); 25 26 /// <summary> 27 /// Attempts to remove the provided login information from the specified <paramref name="user"/>. 28 /// and returns a flag indicating whether the removal succeed or not. 29 /// </summary> 30 /// <param name="user">The user to remove the login information from.</param> 31 /// <param name="loginProvider">The login provide whose information should be removed.</param> 32 /// <param name="providerKey">The key given by the external login provider for the specified user.</param> 33 /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> 34 /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns> RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken)35 Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken); 36 37 /// <summary> 38 /// Retrieves the associated logins for the specified <param ref="user"/>. 39 /// </summary> 40 /// <param name="user">The user whose associated logins to retrieve.</param> 41 /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> 42 /// <returns> 43 /// The <see cref="Task"/> for the asynchronous operation, containing a list of <see cref="UserLoginInfo"/> for the specified <paramref name="user"/>, if any. 44 /// </returns> GetLoginsAsync(TUser user, CancellationToken cancellationToken)45 Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken); 46 47 /// <summary> 48 /// Retrieves the user associated with the specified login provider and login provider key. 49 /// </summary> 50 /// <param name="loginProvider">The login provider who provided the <paramref name="providerKey"/>.</param> 51 /// <param name="providerKey">The key provided by the <paramref name="loginProvider"/> to identify a user.</param> 52 /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> 53 /// <returns> 54 /// The <see cref="Task"/> for the asynchronous operation, containing the user, if any which matched the specified login provider and key. 55 /// </returns> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)56 Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken); 57 } 58 }