Created
April 16, 2019 04:40
-
-
Save sle-c/fddbc1b6225e82ef05582f2cd8f58c91 to your computer and use it in GitHub Desktop.
Service to create an App object in database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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