lets enable alert emails
This commit is contained in:
parent
4388b126e2
commit
1dcb3e80c4
12
main.go
12
main.go
|
@ -90,7 +90,7 @@ func Register(username, email, ip string) bool {
|
||||||
log.Printf("scsusers.Register: insert failed: %s\n", err.Error())
|
log.Printf("scsusers.Register: insert failed: %s\n", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if sendRegistrationEmail(email, username, string(pass)) {
|
if SendRegistrationEmail(email, username, string(pass)) {
|
||||||
log.Printf("scsusers.Register: New user registration: %s from %s\n", username, ip)
|
log.Printf("scsusers.Register: New user registration: %s from %s\n", username, ip)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ func RecoverByUsername(username string) {
|
||||||
qq := fmt.Sprintf("update %s_auth set recoverycode=$1, recoverytime=NOW() where username = $2", c.TablePrefix)
|
qq := fmt.Sprintf("update %s_auth set recoverycode=$1, recoverytime=NOW() where username = $2", c.TablePrefix)
|
||||||
_, err := c.db.Exec(qq, recoverycode, username)
|
_, err := c.db.Exec(qq, recoverycode, username)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
sendRecoveryEmail(email, username, string(recoverycode))
|
SendRecoveryEmail(email, username, string(recoverycode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ func RecoverByEmail(e string) {
|
||||||
qq := fmt.Sprintf("update %s_auth set recoverycode=$1, recoverytime=NOW() where username = $2", c.TablePrefix)
|
qq := fmt.Sprintf("update %s_auth set recoverycode=$1, recoverytime=NOW() where username = $2", c.TablePrefix)
|
||||||
_, err := c.db.Exec(qq, recoverycode, username)
|
_, err := c.db.Exec(qq, recoverycode, username)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
sendRecoveryEmail(email, username, string(recoverycode))
|
SendRecoveryEmail(email, username, string(recoverycode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ func randBytes(n int) []byte {
|
||||||
return []byte(base32.StdEncoding.EncodeToString(randomBytes)[:n])
|
return []byte(base32.StdEncoding.EncodeToString(randomBytes)[:n])
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendRegistrationEmail(recipient, username, password string) bool {
|
func SendRegistrationEmail(recipient, username, password string) bool {
|
||||||
data := struct {
|
data := struct {
|
||||||
SiteName string
|
SiteName string
|
||||||
FromEmail string
|
FromEmail string
|
||||||
|
@ -337,7 +337,7 @@ func sendRegistrationEmail(recipient, username, password string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendAlertEmail(username, recipient, message string) bool {
|
func SendAlertEmail(username, recipient, message string) bool {
|
||||||
data := struct {
|
data := struct {
|
||||||
SiteName string
|
SiteName string
|
||||||
FromEmail string
|
FromEmail string
|
||||||
|
@ -365,7 +365,7 @@ func sendAlertEmail(username, recipient, message string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendRecoveryEmail(recipient, username, code string) bool {
|
func SendRecoveryEmail(recipient, username, code string) bool {
|
||||||
data := struct {
|
data := struct {
|
||||||
SiteName string
|
SiteName string
|
||||||
FromEmail string
|
FromEmail string
|
||||||
|
|
Loading…
Reference in New Issue