· 6 years ago · Apr 26, 2019, 05:20 PM
1package app
2
3import (
4 "fmt"
5
6 "github.com/omnisyle/goliauth"
7)
8
9func CreateApp(name, dbURL string) *App {
10 publicKey := goliauth.NewRandomKey()
11 secretKey := goliauth.NewRandomKey()
12 encryptedSecret, err := goliauth.Encrypt(secretKey)
13
14 if err != nil {
15 panic(err)
16 }
17
18 app := &App{
19 dbURL: dbURL,
20 Name: name,
21 PublicKey: fmt.Sprintf("%x", publicKey),
22 SecretKey: fmt.Sprintf("%x", secretKey),
23 EncryptedSecret: fmt.Sprintf("%x", encryptedSecret),
24 }
25
26 return app.Create()
27}