1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: add basic sign up instructions

This commit is contained in:
Ferdinand Mütsch
2020-05-24 21:42:15 +02:00
parent 2cca2cb0bb
commit 625994d1e9
8 changed files with 57 additions and 12 deletions

View File

@@ -16,6 +16,7 @@ var cfg *Config
type Config struct {
Env string
Version string
Port int
Addr string
BasePath string
@@ -56,11 +57,28 @@ func LookupFatal(key string) string {
return v
}
func readVersion() string {
file, err := os.Open("version.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
bytes, err := ioutil.ReadAll(file)
if err != nil {
log.Fatal(err)
}
return string(bytes)
}
func readConfig() *Config {
if err := godotenv.Load(); err != nil {
log.Fatal(err)
}
version := readVersion()
env := LookupFatal("ENV")
dbType := LookupFatal("WAKAPI_DB_TYPE")
dbUser := LookupFatal("WAKAPI_DB_USER")
@@ -131,6 +149,7 @@ func readConfig() *Config {
return &Config{
Env: env,
Version: version,
Port: port,
Addr: addr,
BasePath: basePath,

View File

@@ -16,3 +16,9 @@ type Signup struct {
Password string `schema:"password"`
PasswordRepeat string `schema:"password_repeat"`
}
func (s *Signup) IsValid() bool {
return len(s.Username) >= 3 &&
len(s.Password) >= 6 &&
s.Password == s.PasswordRepeat
}