fix: update docker file

This commit is contained in:
Lakhan Samani 2021-07-27 17:46:02 +05:30
parent 30f83aaf82
commit 0fd4f18dc1
5 changed files with 20 additions and 10 deletions

View File

@ -1,10 +1,11 @@
FROM golang:1.16-alpine as builder
WORKDIR /app
COPY . .
RUN apk add build-base && cd server && go mod download && go build && chmod 777 server && ls -l
RUN apk add build-base &&\
cd server && \
go mod download && \
go build && \
chmod 777 server
FROM alpine:latest
RUN apk --no-cache add ca-certificates

2
TODO.md Normal file
View File

@ -0,0 +1,2 @@
- [] Add env to disalbe email verification -> this can be helpful while onboarding user
- []

View File

@ -19,6 +19,8 @@ import (
// https://stackoverflow.com/questions/19877246/nodemailer-with-gmail-and-nodejs
**/
// TODO -> try using gomail.v2
type Sender struct {
User string
Password string

View File

@ -49,9 +49,8 @@ func CreateAuthToken(user UserAuthInfo, tokenType enum.TokenType) (string, int64
}
func GetAuthToken(gc *gin.Context) (string, error) {
token := ""
cookie, err := gc.Request.Cookie(constants.COOKIE_NAME)
if err != nil {
token, err := GetCookie(gc)
if err != nil || token == "" {
// try to check in auth header for cookie
log.Println("cookie not found checking headers")
auth := gc.Request.Header.Get("Authorization")
@ -60,10 +59,7 @@ func GetAuthToken(gc *gin.Context) (string, error) {
}
token = strings.TrimPrefix(auth, "Bearer ")
} else {
token = cookie.Value
}
return token, nil
}

View File

@ -24,6 +24,15 @@ func SetCookie(gc *gin.Context, token string) {
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) {
secure := true
httpOnly := true