-
Notifications
You must be signed in to change notification settings - Fork 1
/
account.go
37 lines (31 loc) · 1.09 KB
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package route
import (
"encoding/json"
"github.com/airstrik/airstrik/src/service"
"github.com/airstrik/gobase/pkg/config"
"github.com/airstrik/gobase/pkg/utils"
"log"
"net/http"
)
func CreateAccount(w http.ResponseWriter, r *http.Request) {
ctx := r.Context().Value("AccountCtx").(*config.Context)
log.Print("Log from the Get Account")
// Extract the Payload from the body
email, err := r.Body.Read([]byte("Email"))
_email := string(email)
utils.HandleError(err)
_AccountId := service.GenerateAccountId()
// Create Tenant DB and Run all the Index for that Database
ctx.BaseDB.CreateDB(_AccountId)
// TODO: Run all the Index for the New Tenant Database
username, domain := utils.EmailDomainExtractor(_email)
account := service.CreateAccount(_AccountId, username, _email, domain)
ctx.BaseDB.Create(account)
// Create new User subscription for that Account
//_ = service.CreateNewUser(_email)
_ = json.NewEncoder(w).Encode(utils.GenerateSuccessResponse())
}
// Get the Account from the database
func GetAccount(w http.ResponseWriter, r *http.Request) {
log.Print("Log from the Get Account")
}