Skip to content

Commit

Permalink
Update auth.go
Browse files Browse the repository at this point in the history
  • Loading branch information
PreetinderSinghBadesha authored Jul 4, 2024
1 parent 086af5f commit e7fa57e
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions backend/pkg/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package auth

import (
// "fmt"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -121,29 +120,6 @@ func Login(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(Response{Status: "success", RedirectUrl: url})
}

func Register(w http.ResponseWriter, r *http.Request) {
var userData struct {
Username string `json:"user"`
Password string `json:"pass"`
}

if err := json.NewDecoder(r.Body).Decode(&userData); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

if _, exists := users[userData.Username]; exists {
http.Error(w, "User already exists", http.StatusBadRequest)
return
}

users[userData.Username] = userData.Password

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]string{"message": "User registered successfully"})
}

func GetUsers() []*User {
password, _ := bcrypt.GenerateFromPassword([]byte("12345"), 8)

Expand Down

0 comments on commit e7fa57e

Please sign in to comment.