Skip to content

Instantly share code, notes, and snippets.

@sle-c
Created April 16, 2019 04:40
Show Gist options
  • Save sle-c/fddbc1b6225e82ef05582f2cd8f58c91 to your computer and use it in GitHub Desktop.
Save sle-c/fddbc1b6225e82ef05582f2cd8f58c91 to your computer and use it in GitHub Desktop.
Service to create an App object in database
package app
import (
"fmt"
"github.com/omnisyle/goliauth"
)
func CreateApp(name, dbURL string) *App {
publicKey := goliauth.NewRandomKey()
secretKey := goliauth.NewRandomKey()
encryptedSecret, err := goliauth.Encrypt(secretKey)
if err != nil {
panic(err)
}
app := &App{
dbURL: dbURL,
Name: name,
PublicKey: fmt.Sprintf("%x", publicKey),
SecretKey: fmt.Sprintf("%x", secretKey),
EncryptedSecret: fmt.Sprintf("%x", encryptedSecret),
}
return app.Create()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment