Skip to content

Commit

Permalink
Registerpage added
Browse files Browse the repository at this point in the history
  • Loading branch information
alnck committed Feb 14, 2022
1 parent 7c1136f commit 2719bbc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
15 changes: 13 additions & 2 deletions src/handler/userHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ import (
func CreateUser(context *gin.Context) {
var loginObj models.LoginRequest

if !shouldBindJSON(context, &loginObj) {
return
context.MultipartForm()
for key, value := range context.Request.PostForm {
if key == "Username" {
loginObj.UserName = value[0]
} else if key == "password" {
loginObj.Password = value[0]
}
}

if loginObj.UserName == "" && loginObj.Password == "" {
if !shouldBindJSON(context, &loginObj) {
return
}
}

if err := loginObj.IsValid(); err != nil {
Expand Down
46 changes: 22 additions & 24 deletions src/templates/views/register.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<!DOCTYPE html>
<html>
<body>

<h2>Account Registration</h2><br>
<ul>
<li>usernames must contain only letters or numbers</li>
<li>usernames must be longer than 4 characters but shorter than 51</li>
<li>passwords must contain a uppercase letter, lowercase letter, number, and special character</li>
<li>passwords must be greater than 11 characters but less than 60</li>
</ul><br>

<form action="/registerauth" method="POST">
<label for="username">Name:</label><br>
<input type="text" id="username" name="username"><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="Submit">
</form>

<br><br>
{{if .}}
{{.}}
{{end}}

</body>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/signin.css" rel="stylesheet">
</head>
<body class="text-center">
<form action="/user" method="post" class="form-signin">
<h1 class="h3 mb-3 font-weight-normal">Kayıt</h1>
<input type="inputUsername" name="Username" class="form-control" placeholder="Username" >
<input type="inputPassword" name="password" class="form-control mt-1" placeholder="Şifre" required="">
<!-- <div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Beni hatırla
</label>
</div>-->
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">Kayır Ol</button>
</form>
</body>
</html>

0 comments on commit 2719bbc

Please sign in to comment.