123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div class="modal is-active">
- <div
- class="modal-background"
- @click="
- closeModal({
- sector: 'header',
- modal: 'login'
- })
- "
- />
- <div class="modal-card">
- <header class="modal-card-head">
- <p class="modal-card-title">
- Login
- </p>
- <button
- class="delete"
- @click="
- closeModal({
- sector: 'header',
- modal: 'login'
- })
- "
- />
- </header>
- <section class="modal-card-body">
- <!-- validation to check if exists http://bulma.io/documentation/elements/form/ -->
- <label class="label">Email</label>
- <p class="control">
- <input
- v-model="email"
- class="input"
- type="text"
- placeholder="Email..."
- />
- </p>
- <label class="label">Password</label>
- <p class="control">
- <input
- v-model="password"
- class="input"
- type="password"
- placeholder="Password..."
- @keypress="$parent.submitOnEnter(submitModal, $event)"
- />
- </p>
- <p>
- By logging in/registering you agree to our
- <router-link to="/terms"> Terms of Service </router-link
- > and
- <router-link to="/privacy"> Privacy Policy </router-link>.
- </p>
- </section>
- <footer class="modal-card-foot">
- <a
- class="button is-primary"
- href="#"
- @click="submitModal('login')"
- >Submit</a
- >
- <a
- class="button is-github"
- :href="$parent.serverDomain + '/auth/github/authorize'"
- @click="githubRedirect()"
- >
- <div class="icon">
- <img class="invert" src="/assets/social/github.svg" />
- </div>
- Login with GitHub
- </a>
- <a href="/reset_password" v-on:click="resetPassword()"
- >Forgot password?</a
- >
- </footer>
- </div>
- </div>
- </template>
- <script>
- import { mapActions } from "vuex";
- import { Toast } from "vue-roaster";
- export default {
- data() {
- return {
- email: "",
- password: ""
- };
- },
- methods: {
- submitModal() {
- this.login({
- email: this.email,
- password: this.password
- })
- .then(res => {
- if (res.status === "success") window.location.reload();
- })
- .catch(err => Toast.methods.addToast(err.message, 5000));
- },
- resetPassword() {
- this.closeModal({ sector: "header", modal: "login" });
- this.$router.go("/reset_password");
- },
- githubRedirect() {
- localStorage.setItem("github_redirect", this.$route.path);
- },
- ...mapActions("modals", ["closeModal"]),
- ...mapActions("user/auth", ["login"])
- }
- };
- </script>
- <style lang="scss" scoped>
- .button.is-github {
- background-color: #333;
- color: #fff !important;
- }
- .is-github:focus {
- background-color: #1a1a1a;
- }
- .is-primary:focus {
- background-color: #029ce3 !important;
- }
- .invert {
- filter: brightness(5);
- }
- a {
- color: #029ce3;
- }
- </style>
|