Commit cf618298 authored by PietroDC12's avatar PietroDC12

alt1

parent a671ffc7
......@@ -58,6 +58,7 @@ export default {
await this.login(this.user);
// this.$router.push( { path: '/' })
} catch (error) {
alert('erro no login')
console.log("Erro de Login: ", error);
}
}
......
......@@ -55,7 +55,7 @@
</a>
<a class="btn btn-outline-dark my-2 my-sm-0"
v-else
v-on:click="login"
href="/login"
>
Entrar
......
......@@ -94,7 +94,7 @@
class="fadeIn fourth"
style="font-weight: bold"
value="Cadastrar"
v-on:click="addPessoa()"
v-on:click.prevent="addPessoa()"
/>
</form>
</div>
......@@ -149,11 +149,7 @@ export default {
},
addPessoa() {
axios
.post("http://localhost:8000/api/pessoas/add/", this.pessoa, {
headers: {
Authorization: `Token ${this.$session.get("token")}`,
},
})
.post("/api/pessoas/add/", this.pessoa)
.then((response) => {
this.dialog = false;
this.$emit("updatePessoa");
......
......@@ -41,7 +41,7 @@ export default new VueRouter({
component: CampanhaList
},
{
path: '/campanhaListUni',
path: '/campanhaListUni/:campanha_id',
name: 'CampanhaListUni',
component: CampanhaListUni
},
......
......@@ -4,14 +4,15 @@ class AuthApi {
async login(user) {
try {
const { data } = await axios.post('api/auth/token/', user)
if (data.access) {
axios.defaults.headers.common['Authorization'] = `Bearer ${data.access}`
}
return data
} catch(e) {
console.log(e)
} catch (error) {
return Promise.reject(error)
}
}
}
}
export default new AuthApi()
\ No newline at end of file
......@@ -18,17 +18,19 @@ export const auth = {
},
actions: {
login({ commit }, user) {
return AuthApi.login(user).then( (user) => {
commit('loginSuccess', user)
return Promise.resolve(user)
}, (error) => {
commit('loginFailure')
return Promise.reject(error)
async login({ commit }, user) {
try {
const userData = await AuthApi.login(user)
console.log(userData)
commit('loginSuccess', userData)
return Promise.resolve(userData)
} catch (error) {
commit('loginFailure')
return Promise.reject(error)
}
)
},
}
},
mutations: {
loginSuccess(state, user) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment