kopia lustrzana https://github.com/reiver/greatape
fix(app): 🚑 resolve profile issue
rodzic
8e55c8e72a
commit
57af3d2fb6
|
@ -33,17 +33,17 @@ type VerifyResponse struct {
|
||||||
type User struct {
|
type User struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
DisplayName string `json:"display_name,omitempty"`
|
DisplayName string `json:"display_name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"-"`
|
Password string `json:"-"`
|
||||||
Bio string `json:"bio,omitempty"`
|
Bio string `json:"bio"`
|
||||||
Github string `json:"github,omitempty"`
|
Github string `json:"github"`
|
||||||
Avatar string `json:"avatar,omitempty"`
|
Avatar string `json:"avatar"`
|
||||||
Banner string `json:"banner,omitempty"`
|
Banner string `json:"banner"`
|
||||||
ApiKey string `json:"api_key,omitempty"`
|
ApiKey string `json:"api_key"`
|
||||||
PublicKey string `json:"public_key,omitempty"`
|
PublicKey string `json:"public_key"`
|
||||||
Actor string `json:"actor,omitempty"`
|
Actor string `json:"actor"`
|
||||||
Webfinger string `json:"webfinger,omitempty"`
|
Webfinger string `json:"webfinger"`
|
||||||
PrivateProfile bool `json:"private_profile"`
|
PrivateProfile bool `json:"private_profile"`
|
||||||
} // @name User
|
} // @name User
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ var UpdateProfile = route.New(HttpPost, "/api/v1/profile", func(x IContext) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repos.Default.UpdateProfile(user.ID,
|
if err := repos.Default.UpdateProfile(user.ID,
|
||||||
Values{
|
map[string]interface{}{
|
||||||
"display_name": body.DisplayName,
|
"display_name": body.DisplayName,
|
||||||
"bio": body.Bio,
|
"bio": body.Bio,
|
||||||
"github": body.Github,
|
"github": body.Github,
|
||||||
|
|
|
@ -55,7 +55,12 @@
|
||||||
<form id="frmSignup" action="/api/v1/signup" method="post">
|
<form id="frmSignup" action="/api/v1/signup" method="post">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="username" class="form-label">Username</label>
|
<label for="username" class="form-label">Username</label>
|
||||||
<input type="text" name="username" id="username" class="form-control" />
|
<input
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
id="username"
|
||||||
|
class="form-control"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="email" class="form-label">Email</label>
|
<label for="email" class="form-label">Email</label>
|
||||||
|
@ -123,8 +128,24 @@
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
localStorage.setItem("token", response.data.auth.token);
|
axios({
|
||||||
window.location.href = "/profile";
|
method: "post",
|
||||||
|
url: "/api/v1/verify",
|
||||||
|
data: {
|
||||||
|
email: document.getElementById("email").value,
|
||||||
|
code: response.data.code,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(function (response) {
|
||||||
|
localStorage.setItem("token", response.data.auth.token);
|
||||||
|
window.location.href = "/profile";
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
document.getElementById("signupMessage").innerHTML =
|
||||||
|
err.response.data;
|
||||||
|
document.getElementById("signupMessage").style.display =
|
||||||
|
"block";
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
document.getElementById("signupMessage").innerHTML =
|
document.getElementById("signupMessage").innerHTML =
|
||||||
|
|
|
@ -8,11 +8,9 @@ import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Access int64
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ACCESS_PUBLIC Access = iota
|
ACCESS_PUBLIC = 0
|
||||||
ACCESS_PRIVATE
|
ACCESS_PRIVATE = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// User struct defines the user
|
// User struct defines the user
|
||||||
|
@ -29,7 +27,7 @@ type User struct {
|
||||||
PublicKey string
|
PublicKey string
|
||||||
Avatar string
|
Avatar string
|
||||||
Banner string
|
Banner string
|
||||||
Access Access
|
Access int
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateUser create a user entry in the user's table
|
// CreateUser create a user entry in the user's table
|
||||||
|
|
Ładowanie…
Reference in New Issue