Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signIn() {
- const session_url = 'http://127.0.0.1:5000/signin'
- axios.get(session_url, {}, {
- auth: {
- username: this.email,
- password: this.password
- }
- }).then(response => {
- console.log('Authenticated')
- console.log(response.data)
- /*this.$store.dispatch('signin', response.data)*/
- }).catch(error => {
- console.log('Error on Authentication')
- this.error = error
- console.log(error)
- });
- }
- curl -u Hans:testing -i -X GET http://127.0.0.1:5000/signin
- HTTP/1.0 200 OK
- Content-Type: application/json
- Content-Length: 180
- Access-Control-Allow-Origin: *
- Server: Werkzeug/0.14.1 Python/3.6.4
- Date: Sat, 22 Sep 2018 14:22:37 GMT
- {
- "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...."
- }
- axios.get(session_url, {params : {username: 'x', password:'y'}}).then()
- from flask import request
- @app.route('/signin', methods=['GET', 'POST'])
- def login():
- if request.method == 'POST':
- return do_the_login()
- else:
- return show_the_login_form()
- signIn() {
- //check code
- console.log("email",this.email);
- console.log("pass", this.password);
- const session_url = 'http://127.0.0.1:5000/signin'
- axios.get(session_url, {}, {
- auth: {
- username: this.email,
- password: this.password
- }
- }).then(response => {
- console.log(response);
- //console.log('Authenticated')
- //console.log(response.data)
- /*this.$store.dispatch('signin', response.data)*/
- }).catch(error => {
- console.log('Error on Authentication')
- this.error = error
- console.log(error)
- });
- }
- signIn() {
- const session_url = 'http://127.0.0.1:5000/signin'
- var username = this.email
- var password = this.password
- axios({
- method: 'get',
- url: session_url,
- auth: {
- username: username,
- password: password
- }
- })
- .then(response => {
- console.log('Authenticated')
- console.log(response.data)
- /*this.$store.dispatch('signin', response.data)*/
- }).catch(error => {
- console.log('Error on Authentication')
- this.error = error
- console.log(error)
- });
- }
Add Comment
Please, Sign In to add comment