Starting changes to the API
parent
de3c682194
commit
8ab665c987
|
|
@ -42,10 +42,20 @@ func Login(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
|
||||
Issuer: strconv.Itoa(int(user.Id)),
|
||||
ExpiresAt: time.Now().Add(time.Hour * 1).Unix(),
|
||||
})
|
||||
type customClaims struct {
|
||||
Userid string `json:"user"`
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
tok := customClaims{
|
||||
Userid: strconv.Itoa(int(user.Id)),
|
||||
StandardClaims: jwt.StandardClaims{
|
||||
Issuer: strconv.Itoa(int(user.Id)),
|
||||
ExpiresAt: time.Now().Add(time.Hour * 1).Unix(),
|
||||
},
|
||||
}
|
||||
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, tok)
|
||||
|
||||
token, err := claims.SignedString([]byte(os.Getenv("API_SECRET")))
|
||||
if err != nil {
|
||||
|
|
@ -99,6 +109,7 @@ func AddUser(c *fiber.Ctx) error {
|
|||
Blocked: "N",
|
||||
First: "S",
|
||||
Cancelled: "N",
|
||||
CreatedBy: data["creator"],
|
||||
}
|
||||
|
||||
database.DB.Create(&user)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
h3[data-v-b9167eee]{margin:40px 0 0}ul[data-v-b9167eee]{list-style-type:none;padding:0}li[data-v-b9167eee]{display:inline-block;margin:0 10px}a[data-v-b9167eee]{color:#42b983}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
|
|
@ -0,0 +1 @@
|
|||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>transmitterui</title><link href="/css/app.fb0c6e1c.css" rel="preload" as="style"><link href="/js/app.e0347ad3.js" rel="preload" as="script"><link href="/js/chunk-vendors.8e959ed8.js" rel="preload" as="script"><link href="/css/app.fb0c6e1c.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but transmitterui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.8e959ed8.js"></script><script src="/js/app.e0347ad3.js"></script></body></html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(function(e){function t(t){for(var n,a,u=t[0],s=t[1],i=t[2],p=0,v=[];p<u.length;p++)a=u[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&v.push(o[a][0]),o[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);c&&c(t);while(v.length)v.shift()();return l.push.apply(l,i||[]),r()}function r(){for(var e,t=0;t<l.length;t++){for(var r=l[t],n=!0,u=1;u<r.length;u++){var s=r[u];0!==o[s]&&(n=!1)}n&&(l.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={app:0},l=[];function a(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/";var u=window["webpackJsonp"]=window["webpackJsonp"]||[],s=u.push.bind(u);u.push=t,u=u.slice();for(var i=0;i<u.length;i++)t(u[i]);var c=s;l.push([0,"chunk-vendors"]),r()})({0:function(e,t,r){e.exports=r("56d7")},"034f":function(e,t,r){"use strict";r("85ec")},4805:function(e,t,r){"use strict";r("8ce0")},"56d7":function(e,t,r){"use strict";r.r(t);r("e260"),r("e6cf"),r("cca6"),r("a79d");var n=r("2b0e"),o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("img",{attrs:{alt:"Vue logo",src:r("cf05")}}),n("HelloWorld",{attrs:{msg:"Welcome to Your Vue.js App"}})],1)},l=[],a=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"hello"},[r("h1",[e._v(e._s(e.msg))]),e._m(0),r("h3",[e._v("Installed CLI Plugins")]),e._m(1),r("h3",[e._v("Essential Links")]),e._m(2),r("h3",[e._v("Ecosystem")]),e._m(3)])},u=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("p",[e._v(" For a guide and recipes on how to configure / customize this project,"),r("br"),e._v(" check out the "),r("a",{attrs:{href:"https://cli.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-cli documentation")]),e._v(". ")])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel",target:"_blank",rel:"noopener"}},[e._v("babel")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint",target:"_blank",rel:"noopener"}},[e._v("eslint")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Core Docs")])]),r("li",[r("a",{attrs:{href:"https://forum.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Forum")])]),r("li",[r("a",{attrs:{href:"https://chat.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Community Chat")])]),r("li",[r("a",{attrs:{href:"https://twitter.com/vuejs",target:"_blank",rel:"noopener"}},[e._v("Twitter")])]),r("li",[r("a",{attrs:{href:"https://news.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("News")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://router.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-router")])]),r("li",[r("a",{attrs:{href:"https://vuex.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vuex")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-devtools#vue-devtools",target:"_blank",rel:"noopener"}},[e._v("vue-devtools")])]),r("li",[r("a",{attrs:{href:"https://vue-loader.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-loader")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/awesome-vue",target:"_blank",rel:"noopener"}},[e._v("awesome-vue")])])])}],s={name:"HelloWorld",props:{msg:String}},i=s,c=(r("4805"),r("2877")),p=Object(c["a"])(i,a,u,!1,null,"b9167eee",null),v=p.exports,f={name:"App",components:{HelloWorld:v}},h=f,_=(r("034f"),Object(c["a"])(h,o,l,!1,null,null,null)),g=_.exports;n["a"].config.productionTip=!1,new n["a"]({render:function(e){return e(g)}}).$mount("#app")},"85ec":function(e,t,r){},"8ce0":function(e,t,r){},cf05:function(e,t,r){e.exports=r.p+"img/logo.82b9c7a5.png"}});
|
||||
//# sourceMappingURL=app.e0347ad3.js.map
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
go.mod
4
go.mod
|
|
@ -4,13 +4,13 @@ go 1.16
|
|||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.0.2 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/gofiber/fiber/v2 v2.9.0
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/klauspost/compress v1.12.2 // indirect
|
||||
github.com/valyala/fasthttp v1.24.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
|
||||
gorm.io/driver/mysql v1.0.6
|
||||
gorm.io/gorm v1.21.9
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
func main() {
|
||||
app := fiber.New(fiber.Config{
|
||||
StrictRouting: true,
|
||||
StrictRouting: false,
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
|
||||
|
|
@ -20,6 +20,8 @@ func main() {
|
|||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
app.Static("/", "./frontend")
|
||||
|
||||
if err := database.ConnectDB(); err != nil {
|
||||
panic("Could not connect to database")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ type User struct {
|
|||
Blocked string `gorm:"size:1;not null;default:N" json:"blocked"`
|
||||
First string `gorm:"size:1;not null;default:S" json:"first"`
|
||||
Cancelled string `gorm:"size:1;not null;default:N" json:"cancelled"`
|
||||
CreatedBy string `gorm:"size:15;not null;default:Manual" json:"createdby"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue