forked from AcaMate/AcaMate_API
1. 카카오 로그인 인증 snsID 받아오기 2. 리다이렉트 동작 수정 3. 세션을 통한 토큰 저장 3.1. 세션서비스 생성 4. 회원가입 화면으로 이동
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using Back.Program.Services.V1.Interfaces;
|
|
|
|
namespace Back.Program.Services.V1;
|
|
|
|
public class SessionService: ISessionService
|
|
{
|
|
private readonly IHttpContextAccessor _http;
|
|
public SessionService(IHttpContextAccessor http)
|
|
{
|
|
_http = http;
|
|
}
|
|
public Task<bool> SetString(string key, string value)
|
|
{
|
|
try
|
|
{
|
|
_http.HttpContext.Session.SetString(key, value);
|
|
return Task.FromResult(true);
|
|
}
|
|
catch
|
|
{
|
|
return Task.FromResult(false);
|
|
}
|
|
}
|
|
public Task<(bool result, string data)> GetString(string key)
|
|
{
|
|
try
|
|
{
|
|
var value = _http.HttpContext.Session.GetString(key);
|
|
return Task.FromResult((true, value ?? string.Empty));
|
|
}
|
|
catch
|
|
{
|
|
return Task.FromResult((false, ""));
|
|
}
|
|
}
|
|
public Task<bool> Remove(string key)
|
|
{
|
|
try
|
|
{
|
|
_http.HttpContext.Session.Remove(key);
|
|
return Task.FromResult(true);
|
|
}
|
|
catch
|
|
{
|
|
return Task.FromResult(false);
|
|
}
|
|
}
|
|
|
|
|
|
} |