first commits 3

This commit is contained in:
Zeni Kim 2024-09-12 18:15:38 -05:00
parent b3fc6d25ca
commit 6dc72d3e14
28 changed files with 1095 additions and 0 deletions

19
utils/helpers.go Normal file
View file

@ -0,0 +1,19 @@
// Copyright 2023 Harran Ali <harran.m@gmail.com>. All rights reserved.
// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
// Use of this source code is governed by MIT-style
// license that can be found in the LICENSE file.
package utils
import (
"crypto/md5"
"fmt"
)
// generate a hashed string to be used as key for caching auth jwt token
func CreateAuthTokenHashedCacheKey(userID uint, userAgent string) string {
cacheKey := fmt.Sprintf("userid:_%v_useragent:_%v_jwt_token", userID, userAgent)
hashedCacheKey := fmt.Sprintf("%v", fmt.Sprintf("%x", md5.Sum([]byte(cacheKey))))
return hashedCacheKey
}