Browse Source

Authy

hkremer/rebranding
Gregory Rudolph 4 years ago
parent
commit
f23dba9454
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 5
      auth.go

5
auth.go

@ -17,9 +17,10 @@ func reqPass(w http.ResponseWriter, r *http.Request) { @@ -17,9 +17,10 @@ func reqPass(w http.ResponseWriter, r *http.Request) {
log.LogInfo("reqPass username is %+v.", username)
var userID string
g, err := dg.Guild(config.GuildID)
log.LogInfo("reqPass guild is %+v.", config.GuildID)
if err == nil {
for _, m := range g.Members {
if m.User.Username == username {
if strings.ToUpper(m.User.Username) == strings.ToUpper(username) {
userID = m.User.ID
log.LogInfo("User ID found for %+v as %+v", username, userID)
}
@ -28,6 +29,7 @@ func reqPass(w http.ResponseWriter, r *http.Request) { @@ -28,6 +29,7 @@ func reqPass(w http.ResponseWriter, r *http.Request) {
log.LogError("Unable to find user ID for %+v", username)
}
ipaddr := r.Header.Get("X-Real-IP")
log.LogInfo("reqPass IP is %+v.", ipaddr)
log.LogInfo(fmt.Sprintf("reqPass called:```username: %s\nip : %s```", username, ipaddr))
go sendPassword(userID, ipaddr)
http.Redirect(w, r, "/login", 302)
@ -101,6 +103,7 @@ func genPassword(length int) string { @@ -101,6 +103,7 @@ func genPassword(length int) string {
}
func sendPassword(user string, ipaddr string) {
defer log.PanicSafe()
log.LogInfo("sending password to %+v for %+v", ipaddr, user)
str := genPassword(8)
m, _ := dg.GuildMember(config.GuildID, user)
toks[m.User.Username] = tokens{

Loading…
Cancel
Save