fix: update docker file
This commit is contained in:
parent
30f83aaf82
commit
0fd4f18dc1
|
@ -1,10 +1,11 @@
|
||||||
FROM golang:1.16-alpine as builder
|
FROM golang:1.16-alpine as builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN apk add build-base &&\
|
||||||
RUN apk add build-base && cd server && go mod download && go build && chmod 777 server && ls -l
|
cd server && \
|
||||||
|
go mod download && \
|
||||||
|
go build && \
|
||||||
|
chmod 777 server
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
2
TODO.md
Normal file
2
TODO.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- [] Add env to disalbe email verification -> this can be helpful while onboarding user
|
||||||
|
- []
|
|
@ -19,6 +19,8 @@ import (
|
||||||
// https://stackoverflow.com/questions/19877246/nodemailer-with-gmail-and-nodejs
|
// https://stackoverflow.com/questions/19877246/nodemailer-with-gmail-and-nodejs
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
// TODO -> try using gomail.v2
|
||||||
|
|
||||||
type Sender struct {
|
type Sender struct {
|
||||||
User string
|
User string
|
||||||
Password string
|
Password string
|
||||||
|
|
|
@ -49,9 +49,8 @@ func CreateAuthToken(user UserAuthInfo, tokenType enum.TokenType) (string, int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAuthToken(gc *gin.Context) (string, error) {
|
func GetAuthToken(gc *gin.Context) (string, error) {
|
||||||
token := ""
|
token, err := GetCookie(gc)
|
||||||
cookie, err := gc.Request.Cookie(constants.COOKIE_NAME)
|
if err != nil || token == "" {
|
||||||
if err != nil {
|
|
||||||
// try to check in auth header for cookie
|
// try to check in auth header for cookie
|
||||||
log.Println("cookie not found checking headers")
|
log.Println("cookie not found checking headers")
|
||||||
auth := gc.Request.Header.Get("Authorization")
|
auth := gc.Request.Header.Get("Authorization")
|
||||||
|
@ -60,10 +59,7 @@ func GetAuthToken(gc *gin.Context) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
token = strings.TrimPrefix(auth, "Bearer ")
|
token = strings.TrimPrefix(auth, "Bearer ")
|
||||||
} else {
|
|
||||||
token = cookie.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,15 @@ func SetCookie(gc *gin.Context, token string) {
|
||||||
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", u.Hostname(), secure, httpOnly)
|
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", u.Hostname(), secure, httpOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCookie(gc *gin.Context) (string, error) {
|
||||||
|
cookie, err := gc.Request.Cookie(constants.COOKIE_NAME)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cookie.Value, nil
|
||||||
|
}
|
||||||
|
|
||||||
func DeleteCookie(gc *gin.Context) {
|
func DeleteCookie(gc *gin.Context) {
|
||||||
secure := true
|
secure := true
|
||||||
httpOnly := true
|
httpOnly := true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user