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