DreamineVMS.Web
1.0.0.0
DreamineVMS 에이전트가 제공하는 HLS 카메라 영상을 브라우저에서 관리·재생하는 원격 CCTV 웹 서비스입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
VmsAuthState.cs
이 파일의 문서화 페이지로 가기
1
using
DreamineVMS.Web.Models
;
2
using
Microsoft.AspNetCore.Components.Authorization;
3
using
Microsoft.JSInterop;
4
5
namespace
DreamineVMS.Web.Services.Auth
;
6
15
public
sealed
class
VmsAuthState
16
{
25
private
readonly
VmsSessionService
_sessions
;
34
private
readonly AuthenticationStateProvider
_authenticationStateProvider
;
43
private
readonly
VmsUserService
_users
;
52
private
string
?
_token
;
53
62
public
VmsUser
?
CurrentUser
{
get
;
private
set
; }
71
public
bool
IsAuthenticated
=>
CurrentUser
is not
null
;
72
105
public
VmsAuthState
(
106
VmsSessionService
sessions,
107
AuthenticationStateProvider authenticationStateProvider,
108
VmsUserService
users)
109
{
110
_sessions
= sessions;
111
_authenticationStateProvider
= authenticationStateProvider;
112
_users
= users;
113
}
114
139
public
async Task
RestoreAsync
(IJSRuntime js)
140
{
141
if
(
IsAuthenticated
)
return
;
142
143
var authState = await
_authenticationStateProvider
.GetAuthenticationStateAsync();
144
var sharedUser = await
_users
.EnsureExternalUserAsync(authState.User);
145
if
(sharedUser is not
null
)
146
{
147
CurrentUser
= sharedUser;
148
_token
=
_sessions
.CreateSession(sharedUser);
149
await js.InvokeVoidAsync(
"localStorage.setItem"
,
"vms_session"
,
_token
);
150
return
;
151
}
152
153
try
154
{
155
var token = await js.InvokeAsync<
string
?>(
"localStorage.getItem"
,
"vms_session"
);
156
var user =
_sessions
.ValidateToken(token);
157
if
(user is not
null
)
158
{
159
_token
= token;
160
CurrentUser
= user;
161
}
162
}
163
catch
{
/* 서킷 아직 연결 안 된 경우 무시 */
}
164
}
165
206
public
async Task
SignInAsync
(IJSRuntime js,
VmsUser
user,
string
token)
207
{
208
_token
= token;
209
CurrentUser
= user;
210
await js.InvokeVoidAsync(
"localStorage.setItem"
,
"vms_session"
, token);
211
}
212
237
public
async Task
SignOutAsync
(IJSRuntime js)
238
{
239
_sessions
.RemoveSession(
_token
);
240
_token
=
null
;
241
CurrentUser
=
null
;
242
await js.InvokeVoidAsync(
"localStorage.removeItem"
,
"vms_session"
);
243
}
244
}
DreamineVMS.Web.Models
Definition
CameraDevice.cs:1
DreamineVMS.Web.Services.Auth
Definition
VmsAuthState.cs:5
DreamineVMS.Web.Models.VmsUser
Definition
VmsUser.cs:12
DreamineVMS.Web.Services.Auth.VmsAuthState.SignOutAsync
async Task SignOutAsync(IJSRuntime js)
Definition
VmsAuthState.cs:237
DreamineVMS.Web.Services.Auth.VmsAuthState.IsAuthenticated
bool IsAuthenticated
Definition
VmsAuthState.cs:71
DreamineVMS.Web.Services.Auth.VmsAuthState._token
string? _token
Definition
VmsAuthState.cs:52
DreamineVMS.Web.Services.Auth.VmsAuthState.RestoreAsync
async Task RestoreAsync(IJSRuntime js)
Definition
VmsAuthState.cs:139
DreamineVMS.Web.Services.Auth.VmsAuthState.SignInAsync
async Task SignInAsync(IJSRuntime js, VmsUser user, string token)
Definition
VmsAuthState.cs:206
DreamineVMS.Web.Services.Auth.VmsAuthState.CurrentUser
VmsUser? CurrentUser
Definition
VmsAuthState.cs:62
DreamineVMS.Web.Services.Auth.VmsAuthState._authenticationStateProvider
readonly AuthenticationStateProvider _authenticationStateProvider
Definition
VmsAuthState.cs:34
DreamineVMS.Web.Services.Auth.VmsAuthState._users
readonly VmsUserService _users
Definition
VmsAuthState.cs:43
DreamineVMS.Web.Services.Auth.VmsAuthState.VmsAuthState
VmsAuthState(VmsSessionService sessions, AuthenticationStateProvider authenticationStateProvider, VmsUserService users)
Definition
VmsAuthState.cs:105
DreamineVMS.Web.Services.Auth.VmsAuthState._sessions
readonly VmsSessionService _sessions
Definition
VmsAuthState.cs:25
DreamineVMS.Web.Services.Auth.VmsSessionService
Definition
VmsSessionService.cs:15
DreamineVMS.Web.Services.Auth.VmsUserService
Definition
VmsUserService.cs:19
Services
Auth
VmsAuthState.cs
다음에 의해 생성됨 :
1.17.0