Advertisement
Guest User

Untitled

a guest
Nov 26th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. <template>
  2. <div>
  3. <h1>Login</h1>
  4. <div>
  5. <input class="c-game__input" name="username" type="text" v-model="input.username" placeholder="username">
  6. <input class="c-game__input" name="password" type="password" v-model="input.password" placeholder="password">
  7. <button class="c-btn" type="submit" v-on:click="postLogin()">Login</button>
  8. <p>{{welcome}}</p>
  9. </div>
  10.  
  11. </div>
  12. </template>
  13.  
  14. <script>
  15. // @ is an alias to /src
  16. import axios from "axios";
  17.  
  18. export default {
  19. name: "Login",
  20. components: {},
  21. props: ["mockAccount"],
  22. data() {
  23. return {
  24. input: {
  25. username: "",
  26. password: ""
  27. },
  28. welcome: ""
  29. };
  30. },
  31. methods: {
  32. // login() {
  33. // if (this.input.username != "" && this.input.password != "") {
  34. // if (
  35. // this.input.username == "LennertVanHowest" &&
  36. // this.input.password == "LennertVanHowestP@ssw0rd"
  37. // ) {
  38. // this.$emit("authenticated", true);
  39. // this.$router.replace({ name: "createGame" });
  40. // this.$store.dispatch('storeUsername', this.input.username);
  41. // } else {
  42. // console.log("The username and / or password is incorrect");
  43. // }
  44. // } else {
  45. // console.log("A username and password must be present");
  46. // }
  47. // },
  48. postLogin() {
  49. axios({
  50. method: "post",
  51. url: "https://blackboxapi20181126121241.azurewebsites.net/api/auth/login",
  52. data: {
  53. userName: this.input.username,
  54. password: this.input.password
  55. },
  56. withCredentials: true
  57. })
  58. .then(response => (this.welcome = response.data))
  59. .catch(e => {
  60. console.log(e);
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66.  
  67. <style lang="scss" scoped>
  68. @import "./src/style/components/components.button";
  69. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement