modified: begushiybashkir/bbvue/src/stores/auth.js

modified:   begushiybashkir/bbvue/src/stores/user.js
	modified:   begushiybashkir/bbvue/src/views/Login.vue
	modified:   begushiybashkir/bbvue/src/views/Register.vue
	modified:   serv_nginx/api_bb/.env
	modified:   serv_nginx/api_bb/cmd/main.go
	modified:   serv_nginx/api_bb/internal/handlers/auth.go
	modified:   serv_nginx/api_bb/internal/handlers/handlers.go
	modified:   serv_nginx/api_bb/internal/models/user.go
	modified:   serv_nginx/api_bb/internal/routes/routes.go
	modified:   serv_nginx/api_bb/internal/service/auth_service.go
	modified:   serv_nginx/api_bb/pkg/logger/logger.go
delete hash pass from auth_service
it is fix the not loging becouse dowble hash password was
password hash is in middlewares

	modified:   begushiybashkir/bbvue/src/stores/auth.js
	modified:   begushiybashkir/bbvue/src/stores/user.js
	modified:   begushiybashkir/bbvue/src/views/Login.vue
	modified:   begushiybashkir/bbvue/src/views/Register.vue
	modified:   serv_nginx/api_bb/.env
	modified:   serv_nginx/api_bb/cmd/main.go
	modified:   serv_nginx/api_bb/internal/handlers/auth.go
	modified:   serv_nginx/api_bb/internal/handlers/handlers.go
	modified:   serv_nginx/api_bb/internal/models/user.go
	modified:   serv_nginx/api_bb/internal/routes/routes.go
	modified:   serv_nginx/api_bb/internal/service/auth_service.go
	modified:   serv_nginx/api_bb/pkg/logger/logger.go
delete hash password from auth_server
becouse is dowble hash was
second hash is beforeCreatehash in User struct
This commit is contained in:
2025-10-12 05:05:40 +05:00
parent ce433e6187
commit fd9be2199c
12 changed files with 264 additions and 114 deletions
+7 -6
View File
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import axios from 'axios'
const API_BASE_URL = 'https://begushiybashkir.ru/api/v1/auth'
const AUTH_API_URL = 'https://begushiybashkir.ru/api/v1/auth'
export const useAuthStore = defineStore('auth', () => {
const user = ref(null)
@@ -48,10 +48,10 @@ export const useAuthStore = defineStore('auth', () => {
error.value = ''
try {
const response = await axios.post(`${API_BASE_URL}/register`, userData)
const response = await axios.post(`${AUTH_API_URL}/register`, userData)
// После успешной регистрации автоматически логинимся
const loginResponse = await axios.post(`${API_BASE_URL}/login`, {
const loginResponse = await axios.post(`${AUTH_API_URL}/login`, {
email: userData.email,
password: userData.password
})
@@ -75,8 +75,9 @@ export const useAuthStore = defineStore('auth', () => {
error.value = ''
try {
const response = await axios.post(`${API_BASE_URL}/login`, credentials)
const response = await axios.post(`${AUTH_API_URL}/login`, credentials)
const { token: authToken, user: userInfo } = response.data
console.log("authToken: " + authToken + "userInfo: " + userInfo)
setToken(authToken)
setUser(userInfo)
@@ -95,7 +96,7 @@ export const useAuthStore = defineStore('auth', () => {
loading.value = true
try {
await axios.post(`${API_BASE_URL}/logout`, {}, {
await axios.post(`${AUTH_API_URL}/logout`, {}, {
headers: {
'Authorization': `Bearer ${token.value}`
}
@@ -115,7 +116,7 @@ export const useAuthStore = defineStore('auth', () => {
error.value = ''
try {
const response = await axios.get(`${API_BASE_URL}/profile`)
const response = await axios.get(`${AUTH_API_URL}/profile`)
setUser(response.data)
return { success: true, data: response.data }
} catch (err) {
-1
View File
@@ -17,7 +17,6 @@ export const useUserStore = defineStore('user', () => {
error.value = ''
try {
// TODO: Заменить на реальный endpoint когда будет доступен
// const response = await axios.get(`${API_BASE_URL}/user/stats`)
// Временные данные для демонстрации
+7 -23
View File
@@ -5,31 +5,15 @@
<form @submit.prevent="handleLogin" class="login-form">
<div class="form-group">
<input
type="email"
placeholder="Email"
class="form-input"
v-model="credentials.email"
required
:disabled="loading"
>
<input type="email" placeholder="Email" class="form-input" v-model="credentials.email" required
:disabled="loading">
</div>
<div class="form-group">
<input
type="password"
placeholder="Пароль"
class="form-input"
v-model="credentials.password"
required
:disabled="loading"
>
<input type="password" placeholder="Пароль" class="form-input" v-model="credentials.password" required
:disabled="loading">
</div>
<button
type="submit"
class="btn btn-primary"
:disabled="loading"
>
<button type="submit" class="btn btn-primary" :disabled="loading">
{{ loading ? 'Вход...' : 'Войти' }}
</button>
@@ -78,7 +62,7 @@ export default {
methods: {
async handleLogin() {
const result = await this.authStore.login(this.credentials)
alert("register success" + result.success + "| data: " + result.data)
if (result.success) {
this.$router.push('/profile')
}
+2 -1
View File
@@ -185,8 +185,9 @@ export default {
}
console.log('Отправка данных регистрации:', { ...registerData, password: '***' })
alert("|" + registerData.email + "|" + registerData.password + "|")
const result = await this.authStore.register(registerData)
alert("register seccess=" + result.success + "| data=" + result.data)
if (result.success) {
// Перенаправляем на страницу профиля после успешной регистрации