Something went wrong. Try again.
A fork of the Cocoon PDS but being made more distributed. forked from willdot.net/cocoon
Something went wrong. Try again.
2.5 kB · 117 lines
Go
at 2fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118package server
import "fmt"
func (s *Server) sendWelcomeMail(email, handle string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("Welcome to " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Welcome to %s! Your handle is %s.", email, handle))
if err := s.mail.Send(); err != nil { return err }
return nil}
func (s *Server) sendPasswordReset(email, handle, code string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("Password reset for " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your password reset code is %s. This code will expire in ten minutes.", handle, code))
if err := s.mail.Send(); err != nil { return err }
return nil}
func (s *Server) sendPlcTokenReset(email, handle, code string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("PLC token for " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your PLC operation code is %s. This code will expire in ten minutes.", handle, code))
if err := s.mail.Send(); err != nil { return err }
return nil}
func (s *Server) sendEmailUpdate(email, handle, code string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("Email update for " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your email update code is %s. This code will expire in ten minutes.", handle, code))
if err := s.mail.Send(); err != nil { return err }
return nil}
func (s *Server) sendEmailVerification(email, handle, code string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("Email verification for " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your email verification code is %s. This code will expire in ten minutes.", handle, code))
if err := s.mail.Send(); err != nil { return err }
return nil}
func (s *Server) sendTwoFactorCode(email, handle, code string) error { if s.mail == nil { return nil }
s.mailLk.Lock() defer s.mailLk.Unlock()
s.mail.To(email) s.mail.Subject("2FA code for " + s.config.Hostname) s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your 2FA code is %s. This code will expire in ten minutes.", handle, code))
if err := s.mail.Send(); err != nil { return err }
return nil}