Guest User

Untitled

a guest
Sep 22nd, 2018
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. signIn() {
  2. const session_url = 'http://127.0.0.1:5000/signin'
  3.  
  4. axios.get(session_url, {}, {
  5. auth: {
  6. username: this.email,
  7. password: this.password
  8. }
  9. }).then(response => {
  10. console.log('Authenticated')
  11. console.log(response.data)
  12. /*this.$store.dispatch('signin', response.data)*/
  13. }).catch(error => {
  14. console.log('Error on Authentication')
  15. this.error = error
  16. console.log(error)
  17. });
  18. }
  19.  
  20. curl -u Hans:testing -i -X GET http://127.0.0.1:5000/signin
  21.  
  22. HTTP/1.0 200 OK
  23. Content-Type: application/json
  24. Content-Length: 180
  25. Access-Control-Allow-Origin: *
  26. Server: Werkzeug/0.14.1 Python/3.6.4
  27. Date: Sat, 22 Sep 2018 14:22:37 GMT
  28.  
  29. {
  30. "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...."
  31. }
  32.  
  33. axios.get(session_url, {params : {username: 'x', password:'y'}}).then()
  34.  
  35. from flask import request
  36.  
  37. @app.route('/signin', methods=['GET', 'POST'])
  38. def login():
  39. if request.method == 'POST':
  40. return do_the_login()
  41. else:
  42. return show_the_login_form()
  43.  
  44. signIn() {
  45. //check code
  46. console.log("email",this.email);
  47. console.log("pass", this.password);
  48. const session_url = 'http://127.0.0.1:5000/signin'
  49. axios.get(session_url, {}, {
  50. auth: {
  51. username: this.email,
  52. password: this.password
  53. }
  54. }).then(response => {
  55. console.log(response);
  56. //console.log('Authenticated')
  57. //console.log(response.data)
  58. /*this.$store.dispatch('signin', response.data)*/
  59. }).catch(error => {
  60. console.log('Error on Authentication')
  61. this.error = error
  62. console.log(error)
  63. });
  64. }
  65.  
  66. signIn() {
  67. const session_url = 'http://127.0.0.1:5000/signin'
  68. var username = this.email
  69. var password = this.password
  70. axios({
  71. method: 'get',
  72. url: session_url,
  73. auth: {
  74. username: username,
  75. password: password
  76. }
  77. })
  78. .then(response => {
  79. console.log('Authenticated')
  80. console.log(response.data)
  81. /*this.$store.dispatch('signin', response.data)*/
  82. }).catch(error => {
  83. console.log('Error on Authentication')
  84. this.error = error
  85. console.log(error)
  86. });
  87. }
Add Comment
Please, Sign In to add comment