<commit_before><template>
    <section>
        <h1 class="title is-3">DB Auth</h1>

        <div class="columns">
            <div class="column is-4 is-offset-4">

                <form v-if="!isAuthenticated">
                    <b-field label="E-mail" expanded>
                        <b-input type="email" placeholder="<EMAIL>" name="email" required v-model="email"></b-input>
                    </b-field>

                    <b-field label="Pass" expanded>
                        <b-input type="password" name="pass" required v-model="pass"></b-input>
                    </b-field>

                    <b-field>
                        <div class="control">
                            <button class="button is-primary is-fullwidth" @click.prevent="signIn">
                                <b-icon icon="database"></b-icon>
                                <span>DB Authorize</span>
                            </button>
                        </div>
                    </b-field>
                </form>

                <form v-if="isAuthenticated">
                    <b-field label="E-mail" expanded>
                        <b-input disabled name="email" :value="user.email"></b-input>
                    </b-field>

                    <b-field>
                        <div class="control">
                            <button class="button is-primary is-fullwidth" @click.prevent="signOut">
                                <b-icon icon="sign-out"></b-icon>
                                <span>Log out</span>
                            </button>
                        </div>
                    </b-field>
                </form>

            </div>

        </div>
    </section>
</template>

<script>
    import { firebaseApp } from '../../../firebase';

    import { mapState } from 'vuex';

    import { DURATION } from '../../../constants/ui';

    export default {
        name: 'auth',

        data () {
            return {
                email: '',
                pass: ''
            };
        },

        computed: {
            ...mapState('user', ['isAuthenticated', 'user'])
        },

        methods: {
            signIn: function () {
                firebaseApp
                    .auth()
                    .signInWithEmailAndPassword(this.email, this.pass)
                    .then(() => {
                        this.$snackbar.open({
                            message: `User ${this.email} is now authorized!`,
                            actionText: 'OK',
                            position: 'is-top',
                            duration: DURATION.NOTIFICATION_NORMAL
                        });

                        this.email = '';
                        this.pass = '';
                    })
                    .catch((error) => {
                        this.$snackbar.open({
                            message: `Sorry, something is wrong: ${error}`,
                            actionText: 'Ouch!',
                            type: 'is-danger',
                            position: 'is-top',
                            duration: DURATION.NOTIFICATION_NORMAL
                        });

                        this.pass = '';
                    });
            },

            signOut: function () {
                firebaseApp
                    .auth()
                    .signOut();<commit_msg>update auth page<commit_after><template>
    <section>
        <h1 class="display-1">
            DB Auth
        </h1>

        <v-container fluid class="pa-0">
            <v-layout row justify-space-around>
                <v-flex d-flex xs4>

                    <v-card>
                        <v-card-text>

                            <form v-if="!isAuthenticated">
                                <v-text-field
                                    label="E-mail"
                                    v-model="email"
                                    required
                                    placeholder="<EMAIL>"
                                    :rules="emailRules"
                                ></v-text-field>

                                <v-text-field
                                    label="Pass"
                                    v-model="pass"
                                    required
                                    type="password"
                                ></v-text-field>

                                <div class="text-xs-center">
                                    <v-btn color="primary" large @click.prevent="signIn">
                                        <v-icon left>storage</v-icon>
                                        <span>DB Authorize</span>
                                    </v-btn>
                                </div>
                            </form>

                            <form v-if="isAuthenticated">
                                <v-text-field
                                    label="E-mail"
                                    v-model="user.email"
                                    disabled
                                ></v-text-field>

                                <div class="text-xs-center">
                                    <v-btn color="primary" large @click.prevent="signOut">
                                        <v-icon left>lock_open</v-icon>
                                        <span>Log out</span>
                                    </v-btn>
                                </div>
                            </form>

                        </v-card-text>
                    </v-card>

                    <v-snackbar
                        :timeout="notification.timeout"
                        v-model="notification.show"
                        top
                    >
                        <span>
                            {{ notification.text }}
                        </span>
                        <v-btn dark flat @click.native="notification.show = false">
                            {{ notification.btnText }}
                        </v-btn>
                    </v-snackbar>
                </v-flex>
            </v-layout>
        </v-container>

    </section>
</template>

<script>
    import { firebaseApp } from '../../../firebase';

    import { mapState } from 'vuex';

    import { DURATION } from '../../../constants/ui';

    export default {
        name: 'auth',

        data () {
            return {
                email: '',
                pass: '',

                emailRules: [
                    (v) => !!v || 'E-mail is required',
                    (v) => /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v) || 'E-mail must be valid'
                ],

                notification: {
                    show: false,
                    text: '',
                    btnText: '',
                    timeout: DURATION.NOTIFICATION_NORMAL
                }
            };
        },

        computed: {
            ...mapState('user', ['isAuthenticated', 'user'])
        },

        methods: {
            signIn: function () {
                firebaseApp
                    .auth()
                    .signInWithEmailAndPassword(this.email, this.pass)
                    .then(() => {
                        this.notification.text = `User ${this.email} is now authorized!`;
                        this.notification.btnText = 'OK';
                        this.notification.show = true;

                        this.email = '';
                        this.pass = '';
                    })
                    .catch((error) => {
                        this.notification.text = `Sorry, something is wrong: ${error}`;
                        this.notification.btnText = 'Ouch!';

                        this.pass = '';
                    });
            },

            signOut: function () {
                firebaseApp
                    .auth()
                    .signOut();
{'fraction_non_alphanumeric': 0.12115118763353022, 'fraction_numerical': 0.0015081060701269322, 'mean_word_length': 0.7326366209449162, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5881086', 'n_tokens_mistral': 1914, 'n_tokens_neox': 1763, 'n_words': 317}