ShopPlatform.Web 1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
로딩중...
검색중...
일치하는것 없음
ShopCustomerLoginSync.cs
이 파일의 문서화 페이지로 가기
2
4
13public sealed class ShopCustomerLoginSync
14{
23 private readonly ShopUserContext _userContext;
41 private readonly ShopCustomerSession _session;
42
76 ShopUserContext userContext,
78 ShopCustomerSession session)
79 {
80 _userContext = userContext;
81 _profiles = profiles;
82 _session = session;
83 }
84
109 public async Task<bool> SyncAsync(string slug)
110 {
111 if (_session.IsLoggedIn)
112 {
113 return true;
114 }
115
116 var user = await _userContext.GetCurrentAsync().ConfigureAwait(false);
117 if (!user.IsAuthenticated)
118 {
119 return false;
120 }
121
122 var profile = await _profiles.GetAsync(slug, user.Id).ConfigureAwait(false);
123 _session.LoginFromCommonUser(user, profile);
124 return true;
125 }
126
183 public async Task SaveProfileAsync(string slug, string name, string phone, string address, string email)
184 {
185 var user = await _userContext.GetCurrentAsync().ConfigureAwait(false);
186 if (!user.IsAuthenticated)
187 {
188 return;
189 }
190
191 var profile = new ShopCustomerProfile
192 {
193 UserId = user.Id,
194 Provider = user.Provider,
195 Email = string.IsNullOrWhiteSpace(email) ? user.Email : email.Trim(),
196 DisplayName = user.DisplayName,
197 Name = string.IsNullOrWhiteSpace(name) ? user.DisplayName : name.Trim(),
198 Phone = phone.Trim(),
199 Address = address.Trim()
200 };
201
202 await _profiles.SaveAsync(slug, profile).ConfigureAwait(false);
203 _session.LoginFromCommonUser(user, profile);
204 }
205}
readonly ShopCustomerProfileStore _profiles
ShopCustomerLoginSync(ShopUserContext userContext, ShopCustomerProfileStore profiles, ShopCustomerSession session)
async Task SaveProfileAsync(string slug, string name, string phone, string address, string email)