Logowanie i rejestracja bez snackbarow
This commit is contained in:
parent
b1ef71f2d9
commit
01323df92f
@ -48,7 +48,8 @@
|
||||
</v-menu>
|
||||
|
||||
<v-btn flat color="grey" @click="userAction">
|
||||
<span v-if="isLogged">Wyloguj</span>
|
||||
<span v-if="isLogged">Wyloguj
|
||||
</span>
|
||||
<span v-if="!isLogged">Zaloguj</span>
|
||||
<v-icon right>exit_to_app</v-icon>
|
||||
</v-btn>
|
||||
|
@ -14,14 +14,19 @@
|
||||
<v-text-field :rules="loginRules" label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-action>
|
||||
<v-btn class="primary" @click="login">
|
||||
<!-- <v-card-actions> -->
|
||||
|
||||
<v-btn align-center justify-center class="primary text-md-center" @click="login">
|
||||
Zaloguj
|
||||
</v-btn>
|
||||
</v-card-action>
|
||||
<!-- </v-card-actions> -->
|
||||
<v-card-text>
|
||||
<v-list-tile router :to="'/register'">
|
||||
<v-list-tile-title class="mt-3 subheading" >Nie masz konta? Zarejestruj się! </v-list-tile-title>
|
||||
<v-list-tile-title class="text">
|
||||
<p class="text-md-center">
|
||||
Nie masz konta? Zarejestruj się!
|
||||
</p>
|
||||
</v-list-tile-title>
|
||||
</v-list-tile>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
@ -40,12 +45,14 @@ export default {
|
||||
userLogin : '',
|
||||
userPassword: '',
|
||||
loginRules: [
|
||||
v => v.length >= 0 || 'Pole nie może być puste'
|
||||
v => v.length > 0 || 'Pole nie może być puste'
|
||||
] //nie sprawdzam hasla, bo to przy rejestracji
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
login(){
|
||||
if (this.$refs.form.validate()){ //valinnaj JS
|
||||
|
||||
axios.post("http://127.0.0.1:3000/api/loginUserView" ,
|
||||
{"login": this.userLogin, "password": this.userPassword},
|
||||
{ crossdomain: true })
|
||||
@ -66,10 +73,9 @@ export default {
|
||||
.catch(error=>{
|
||||
console.log("ERROR: ", error.response.data)
|
||||
});
|
||||
|
||||
}//dlugi if
|
||||
}
|
||||
},
|
||||
goRegister(){
|
||||
console.log("Log register")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -9,15 +9,29 @@
|
||||
</v-avatar>
|
||||
<p class="primary--text mt-3 headline">Edżentelmeni</p>
|
||||
<v-card-text>
|
||||
<v-text-field label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||
<v-text-field label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
<v-text-field label="potwierdź hasło " v-model="userPassword2" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
|
||||
<v-form class="px-3" ref="form">
|
||||
<v-text-field :rules="rulesInput" label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||
<v-text-field :rules="rulesPassword" label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
<v-text-field :rules="rulesPassword" label="potwierdź hasło " v-model="userPassword2" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
<v-text-field label="opis nieobowiązkowy " v-model="userDescription" prepend-icon="favorite"></v-text-field>
|
||||
</v-form>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-action>
|
||||
<v-btn class="primary">
|
||||
<!-- <v-card-actions> -->
|
||||
<v-btn class="primary" @click="register">
|
||||
Zarejestruj
|
||||
</v-btn>
|
||||
</v-card-action>
|
||||
<!-- </v-card-actions> -->
|
||||
<v-card-text>
|
||||
<v-list-tile router :to="'/'">
|
||||
<v-list-tile-title class="mt-3 subheading" >
|
||||
<p class="text-md-center">
|
||||
Masz już konto? Zaloguj się!
|
||||
</p>
|
||||
</v-list-tile-title>
|
||||
</v-list-tile>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
@ -26,16 +40,73 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
data(){
|
||||
return{
|
||||
userLogin : '',
|
||||
userPassword: ''
|
||||
userPassword: '',
|
||||
userPassword2: '',
|
||||
userDescription: '',
|
||||
// rulesPassword: [ v => v.match(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/) || 'Nieprawidłowe hasło'],
|
||||
rulesPassword: [v => v.length > 0 || 'Hasło nie może być puste'],
|
||||
rulesInput: [v => v.length > 0 || 'Pole nie może być puste']
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
login(){
|
||||
console.log("Logowanie uzytkownika")
|
||||
register(){
|
||||
//dodwanie nowego uzytkownika do bazy
|
||||
console.log("Rejestracja uzytkownika")
|
||||
if (this.$refs.form.validate()){ //valinnaj JS
|
||||
console.log("WALIDAJC AOK")
|
||||
|
||||
if (this.userPassword != this.userPassword2){
|
||||
this.rulesPassword= [false || 'Podane hasla różnią się']
|
||||
console.log("Hasla sei roznia")
|
||||
this.userPassword = ''
|
||||
this.userPassword2 = ''
|
||||
return
|
||||
}
|
||||
if(this.userPassword === this.userPassword2){
|
||||
//hasla ok, login ok - to rejestracja w bazie
|
||||
this.rulesPassword = [true || 'Rejestracj']
|
||||
console.log("OK register")
|
||||
|
||||
//dodawanie do bazy
|
||||
axios.post("http://127.0.0.1:3000/api/addNewUserView" ,
|
||||
{"login": this.userLogin, "password": this.userPassword, "userDescription": this.userDescription},
|
||||
{ crossdomain: true })
|
||||
.then(response=>{
|
||||
console.log(response.data);
|
||||
if (response.data === "[addNewUserView] Dodano uzytkownika do bazy"){
|
||||
window.location.replace("http://localhost:8080/");
|
||||
}
|
||||
if (response.data === "Login zajęty"){
|
||||
this.loginRules= [false || 'Login zajęty']
|
||||
}
|
||||
else{
|
||||
//Zły login albo hasło
|
||||
this.loginRules= [false || 'Nieprawidłowe dane']
|
||||
}
|
||||
this.userLogin = ""
|
||||
this.userPassword = ""
|
||||
})
|
||||
|
||||
.catch(error=>{
|
||||
console.log("ERROR: ", error.response.data)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
this.login = ''
|
||||
this.userPassword = ''
|
||||
this.userPassword2 = ''
|
||||
return
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user