<commit_before>import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { LoginService } from '../../service/login.service';

@Component({
    selector: 'app-navbar',
    templateUrl: './navbar.component.html',
    styleUrls: [ './navbar.component.scss' ]
})
export class NavbarComponent implements OnInit {
    loginFormGroup: FormGroup;
    isLogin: boolean;
    isAdmin: boolean;
    id: number;

    constructor (private loginService: LoginService, private fb: FormBuilder) {
    }

    ngOnInit () {
        this.id = +sessionStorage.getItem('id');
        this.id ? this.isLogin = true : this.isLogin = false;

        // todo: server know this id is admin.
        this.id === 20120350 ? this.isAdmin = true : this.isAdmin = false;


        this.loginFormGroup = this.fb.group({
            id: [ '', Validators.required ],
            password: [ '', Validators.required ]
        });
    }

    public login (form: FormGroup) {
        const value = form.value;

        // form에 값 입력 체크
        if ( form.valid ) {
            this.loginService.login(value.id, value.password).subscribe(
                (res: any) => {
                    // 로그인 성공 체크
                    if ( res.result === 'login success' ) {
                        alert(`안녕하세요! ${value.id}님`);
                        sessionStorage.setItem('id', value.id);
                        this.isLogin = true;
                        this.id = value.id;
                    } else {
                        alert(`아이디 혹은 비밀번호가 틀렸습니다.`);
                    }
                },
                (error: any) => {
                    alert(error.message);
                }
            );
        } else {
            if ( form.get('id').invalid ) {
                alert('아이디를 입력해 주세요');
            } else if ( form.get('password').invalid ) {
                alert('비밀번호를 입력해 주세요');
            }
        }
    }
}<commit_msg>로그인 여부, admin 여부 체크 함수 생성<commit_after>import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { LoginService } from '../../service/login.service';

@Component({
    selector: 'app-navbar',
    templateUrl: './navbar.component.html',
    styleUrls: [ './navbar.component.scss' ]
})
export class NavbarComponent implements OnInit {
    loginFormGroup: FormGroup;
    isLogin: boolean;
    isAdmin: boolean;
    id: number;

    constructor (private loginService: LoginService, private fb: FormBuilder) {
    }

    ngOnInit () {
        this.checkUserInfo();
        this.loginFormGroup = this.fb.group({
            id: [ '', Validators.required ],
            password: [ '', Validators.required ]
        });
    }

    public login (form: FormGroup) {
        const value = form.value;

        // form에 값 입력 체크
        if ( form.valid ) {
            this.loginService.login(value.id, value.password).subscribe(
                (res: any) => {
                    // 로그인 성공 체크
                    if ( res.result === 'login success' ) {
                        alert(`안녕하세요! ${value.id}님`);
                        sessionStorage.setItem('id', value.id);
                        this.checkUserInfo();
                    } else {
                        alert(`아이디 혹은 비밀번호가 틀렸습니다.`);
                    }
                },
                (error: any) => {
                    alert(error.message);
                }
            );
        } else {
            if ( form.get('id').invalid ) {
                alert('아이디를 입력해 주세요');
            } else if ( form.get('password').invalid ) {
                alert('비밀번호를 입력해 주세요');
            }
        }
    }

    public checkUserInfo() {
        this.id = +sessionStorage.getItem('id');
        this.id ? this.isLogin = true : this.isLogin = false;
        // todo: server know this id is admin.
        this.id === 20120350 ? this.isAdmin = true : this.isAdmin = false;
    }
}
{'fraction_non_alphanumeric': 0.13165829145728644, 'fraction_numerical': 0.004020100502512563, 'mean_word_length': 1.5037735849056604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4734710', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1263, 'n_words': 248}