1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: guess user timezone on signup

This commit is contained in:
Ferdinand Mütsch 2021-04-25 20:02:45 +02:00
parent 6973743f41
commit 75e61c0dc3
3 changed files with 13 additions and 1 deletions

View File

@ -39,6 +39,7 @@ type Signup struct {
Email string `schema:"email"`
Password string `schema:"password"`
PasswordRepeat string `schema:"password_repeat"`
Location string `schema:"location"`
}
type SetPasswordRequest struct {

View File

@ -76,8 +76,9 @@ func (srv *UserService) Count() (int64, error) {
func (srv *UserService) CreateOrGet(signup *models.Signup, isAdmin bool) (*models.User, bool, error) {
u := &models.User{
ID: signup.Username,
Email: signup.Email,
ApiKey: uuid.NewV4().String(),
Email: signup.Email,
Location: signup.Location,
Password: signup.Password,
IsAdmin: isAdmin,
}

View File

@ -34,6 +34,8 @@
</div>
<form class="mt-10" action="signup" method="post">
<input type="hidden" name="location" id="input-location">
<div class="mb-8">
<label class="inline-block text-sm mb-1 text-gray-500" for="username">Username</label>
<input class="shadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded w-full py-1 px-3"
@ -78,6 +80,14 @@
{{ template "footer.tpl.html" . }}
{{ template "foot.tpl.html" . }}
<script type="text/javascript">
function guessTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone
}
document.getElementById('input-location').setAttribute('value', guessTimezone())
</script>
</body>
</html>