회원 정보 수정

This commit is contained in:
Park Byung Eun 2022-09-30 05:01:07 +00:00
parent 194a720103
commit 4af75c511a
5 changed files with 50 additions and 7 deletions

View File

@ -4,6 +4,8 @@ import { catchError, Observable, of, switchMap, throwError } from 'rxjs';
import { AuthUtils } from 'app/core/auth/auth.utils'; import { AuthUtils } from 'app/core/auth/auth.utils';
import { WebSessionStorageService } from 'app/core/web-storage/services/web-session-storage.service'; import { WebSessionStorageService } from 'app/core/web-storage/services/web-session-storage.service';
import { IdentityService } from 'app/modules/polyglot/identity/services/identity.service'; import { IdentityService } from 'app/modules/polyglot/identity/services/identity.service';
import { MemberService } from 'app/modules/polyglot/member/services/member.service';
import { MemberInfo } from 'app/shared/models/member-info';
@Injectable() @Injectable()
export class AuthService { export class AuthService {
@ -15,6 +17,7 @@ export class AuthService {
constructor( constructor(
private _httpClient: HttpClient, private _httpClient: HttpClient,
private _identityService: IdentityService, private _identityService: IdentityService,
private _memberService: MemberService,
private __webSessionStorageService: WebSessionStorageService private __webSessionStorageService: WebSessionStorageService
) {} ) {}
@ -33,6 +36,21 @@ export class AuthService {
localStorage.setItem('accessToken', token); localStorage.setItem('accessToken', token);
} }
set memberInfo(memberInfo: MemberInfo) {
const info = JSON.stringify(memberInfo);
localStorage.setItem('memberInfo', info);
}
get memberInfo(): MemberInfo {
const info = localStorage.getItem('memberInfo') ?? '';
let result = {} as MemberInfo;
if (info !== '') {
result = JSON.parse(info) as MemberInfo;
}
return result;
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Public methods // @ Public methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -75,6 +93,10 @@ export class AuthService {
res.getAccessToken() res.getAccessToken()
); );
this.memberInfo = {
username: credentials.username,
} as MemberInfo;
// Store the access token in the local storage // Store the access token in the local storage
this.accessToken = res.getAccessToken(); this.accessToken = res.getAccessToken();
@ -121,6 +143,7 @@ export class AuthService {
signOut(): Observable<any> { signOut(): Observable<any> {
// Remove the access token from the local storage // Remove the access token from the local storage
localStorage.removeItem('accessToken'); localStorage.removeItem('accessToken');
localStorage.removeItem('memberInfo');
// Set the authenticated flag to false // Set the authenticated flag to false
this._authenticated = false; this._authenticated = false;

View File

@ -84,19 +84,24 @@
> >
회원아이디 회원아이디
</div> </div>
<div class="font-medium">test님</div> <div class="font-medium">{{ member?.getUsername() }}</div>
<div <div
class="justify-self-end font-medium tracking-tight text-secondary" class="justify-self-end font-medium tracking-tight text-secondary"
> >
보유금액 보유금액
</div> </div>
<div class="font-medium">74,100원</div> <div class="font-medium">
{{
member?.getMemberBalance()?.getBalanceSum()
| currency: "KRW":"symbol"
}}
</div>
<div <div
class="justify-self-end font-medium tracking-tight text-secondary" class="justify-self-end font-medium tracking-tight text-secondary"
> >
콤프 콤프
</div> </div>
<div class="font-medium">3,100P</div> <div class="font-medium">3000P</div>
<div <div
class="justify-self-end font-medium tracking-tight text-secondary" class="justify-self-end font-medium tracking-tight text-secondary"
> >

View File

@ -29,6 +29,8 @@ import { environment } from 'environments/environment';
import { ModifyMemberComposeComponent } from '../compose/compose/modify-member-compose.component'; import { ModifyMemberComposeComponent } from '../compose/compose/modify-member-compose.component';
import { SlotGameComposeComponent } from '../compose/compose/slot-game-compose.component'; import { SlotGameComposeComponent } from '../compose/compose/slot-game-compose.component';
import { MessageComposeComponent } from '../compose/compose/message-compose.component'; import { MessageComposeComponent } from '../compose/compose/message-compose.component';
import { MemberService } from 'app/modules/polyglot/member/services/member.service';
import { MemberModel } from 'app/modules/proto/models/member_pb';
export enum ComposeMenuType { export enum ComposeMenuType {
signIn = 'SignIn', signIn = 'SignIn',
@ -60,6 +62,7 @@ export class HomeComponent implements OnInit {
liveCasinos!: Vendor[]; liveCasinos!: Vendor[];
hotelCasinos!: Vendor[]; hotelCasinos!: Vendor[];
slotGames!: Vendor[]; slotGames!: Vendor[];
member!: MemberModel | undefined;
data = { data = {
schedule: { schedule: {
@ -97,12 +100,17 @@ export class HomeComponent implements OnInit {
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _fuseConfirmationService: FuseConfirmationService, private _fuseConfirmationService: FuseConfirmationService,
private _vendorService: VendorService, private _vendorService: VendorService,
private __gameService: GameService, private _gameService: GameService,
private _memberService: MemberService,
private _authService: AuthService private _authService: AuthService
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
if (!!this.loggedIn) { if (!!this.loggedIn) {
const memberInfo = this._authService.memberInfo;
this._memberService
.getMemberByUsername(memberInfo.username)
.then((res) => (this.member = res.getMember()));
} }
this._vendorService.listVendors().then((result) => { this._vendorService.listVendors().then((result) => {
this.liveCasinos = result this.liveCasinos = result
@ -229,7 +237,7 @@ export class HomeComponent implements OnInit {
private async getGameByParentId( private async getGameByParentId(
parenId: number parenId: number
): Promise<ListGamesResponse.Result> { ): Promise<ListGamesResponse.Result> {
return await this.__gameService.listGames(parenId); return await this._gameService.listGames(parenId);
} }
private openGameWindow(url: string): void { private openGameWindow(url: string): void {
@ -301,7 +309,7 @@ export class HomeComponent implements OnInit {
gameKey = gameList[0].getKey(); gameKey = gameList[0].getKey();
} }
let r = this.__gameService let r = this._gameService
.getGameUrl(vendor.getKey(), gameKey) .getGameUrl(vendor.getKey(), gameKey)
.then((r) => { .then((r) => {
console.log('success', r.getUrl()); console.log('success', r.getUrl());

View File

@ -64,10 +64,13 @@ export class MemberService {
}); });
} }
getMemberByUsername(): Promise<GetMemberByUsernameResponse.Result> { getMemberByUsername(
username: string
): Promise<GetMemberByUsernameResponse.Result> {
return new Promise<GetMemberByUsernameResponse.Result>( return new Promise<GetMemberByUsernameResponse.Result>(
(resolve, reject) => { (resolve, reject) => {
let req = new GetMemberByUsernameRequest(); let req = new GetMemberByUsernameRequest();
req.setUsername(username);
this.__natsService this.__natsService
.request<GetMemberByUsernameResponse.Result>( .request<GetMemberByUsernameResponse.Result>(

View File

@ -0,0 +1,4 @@
export interface MemberInfo {
memberId?: string;
username: string;
}