Replace country with location, add reminder to change non-secure cors settings
This commit is contained in:
parent
0adf6d25f3
commit
d89bba48bd
2 changed files with 6 additions and 5 deletions
1
main.go
1
main.go
|
@ -53,6 +53,7 @@ func main() {
|
|||
func Routes() *chi.Mux {
|
||||
router := chi.NewRouter()
|
||||
// enable cors testing
|
||||
// LOCK THIS DOWN FOR PRODUCTION
|
||||
cors := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@ var (
|
|||
type User struct {
|
||||
Username string `json:"username",db:"username"`
|
||||
Email string `json:"email",db:"email"`
|
||||
Country string `json:"country",db:"country"`
|
||||
Country string `json:"location",db:"location"`
|
||||
Bio string `json:"bio",db:"bio"`
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func Init() {
|
|||
(id SERIAL PRIMARY KEY,
|
||||
username text REFERENCES users (username),
|
||||
email text,
|
||||
country text,
|
||||
location text,
|
||||
bio text)`
|
||||
DB.Exec(dbCreateStatement)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func Routes() *chi.Mux {
|
|||
|
||||
func getUser(w http.ResponseWriter, r *http.Request) {
|
||||
username := chi.URLParam(r, "username")
|
||||
result := DB.QueryRow("SELECT username, email, country, bio FROM user_profiles WHERE username=$1", username)
|
||||
result := DB.QueryRow("SELECT username, email, location, bio FROM user_profiles WHERE username=$1", username)
|
||||
user := User{}
|
||||
err := result.Scan(&user.Username, &user.Email, &user.Country, &user.Bio)
|
||||
fmt.Println(err)
|
||||
|
@ -76,7 +76,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
|
|||
UPDATE user_profiles
|
||||
SET username = $1,
|
||||
email = $2,
|
||||
country = $3,
|
||||
location = $3,
|
||||
bio = $4
|
||||
WHERE username = $5`
|
||||
_, err = DB.Exec(updateProfileStatement, user.Username, user.Email, user.Country, user.Bio, username)
|
||||
|
@ -86,7 +86,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func CreateProfile(username string, email string) {
|
||||
blankProfileStatement := `
|
||||
INSERT INTO user_profiles (username, email, country, bio)
|
||||
INSERT INTO user_profiles (username, email, location, bio)
|
||||
VALUES ($1, $2, $3, $4)`
|
||||
DB.Exec(blankProfileStatement, username, email, "", "")
|
||||
}
|
||||
|
|
Reference in a new issue