Advertisement
Guest User

Untitled

a guest
Jul 15th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "flag"
  5. "fmt"
  6. "log"
  7.  
  8. "code.launchyard.com/root/aircto-backend/config"
  9. "code.launchyard.com/root/aircto-backend/models"
  10. "code.launchyard.com/root/aircto-backend/utils"
  11. )
  12.  
  13. var (
  14. email = flag.String("email", "", "user's email to reset the password")
  15. password = flag.String("password", "", "new password")
  16. )
  17.  
  18. func main() {
  19. flag.Parse()
  20. if *email == "" {
  21. fmt.Print("email: ")
  22. fmt.Scanln(email)
  23. }
  24. if *password == "" {
  25. fmt.Print("new-password: ")
  26. fmt.Scanln(password)
  27. }
  28. models.InitModel(config.DBDriver, fmt.Sprintf(config.DBDataSource))
  29. user, err := models.GetUserByEmail(*email)
  30. if err != nil {
  31. log.Fatalf("error getting user: %v\n", err)
  32. }
  33. user.Password = utils.HashString(*password)
  34. if err := user.Save(); err != nil {
  35. log.Fatalf("error saving new password: %v\n", err)
  36. }
  37. fmt.Println("Password reset success.")
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement