The new Ripple frontend.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

irc.go 801B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "database/sql"
  4. "github.com/gin-gonic/gin"
  5. "zxq.co/ripple/rippleapi/common"
  6. )
  7. func ircGenToken(c *gin.Context) {
  8. ctx := getContext(c)
  9. if ctx.User.ID == 0 {
  10. resp403(c)
  11. return
  12. }
  13. db.Exec("DELETE FROM irc_tokens WHERE userid = ?", ctx.User.ID)
  14. var s, m string
  15. for {
  16. s = common.RandomString(32)
  17. m = cmd5(s)
  18. if db.QueryRow("SELECT 1 FROM irc_tokens WHERE token = ? LIMIT 1", m).
  19. Scan(new(int)) == sql.ErrNoRows {
  20. break
  21. }
  22. }
  23. db.Exec("INSERT INTO irc_tokens(userid, token) VALUES (?, ?)", ctx.User.ID, m)
  24. simple(c, getSimple("/irc"), []message{successMessage{
  25. T(c, "Your new IRC token is <code>%s</code>. The old IRC token is not valid anymore.<br>Keep it safe, don't show it around, and store it now! We won't show it to you again.", s),
  26. }}, nil)
  27. }