generate password when reg script is run

This commit is contained in:
Arya Kiran 2023-01-08 15:48:58 +05:30
parent e74b19616c
commit 5672b6a520
Signed by untrusted user who does not match committer: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 2 additions and 4 deletions

1
go.mod
View File

@ -12,7 +12,6 @@ require (
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sethvargo/go-password v0.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.43.0 // indirect

View File

@ -6,8 +6,6 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/sethvargo/go-password/password"
"github.com/containrrr/shoutrrr"
log "github.com/sirupsen/logrus"
@ -41,8 +39,9 @@ func SignupPage(c *fiber.Ctx) error {
bashscript := "#!/bin/bash \n" +
"# Path: /var/publapi/users/" + username + ".sh\n" +
"# This file is generated by publapi. Do not edit this file.\n" +
"pass=\"$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)\"" +
"useradd -Um -s /bin/bash " + username + "\n" +
"printf \"%s\\n%s\"" + " '" + pass + "' '" + pass + "' | passwd " + username + "\n" +
"printf \"%s\\n%s\" \"${pass}\" \"${pass}\" | passwd " + username + "\n" +
"echo \"" + username + "'s account has been created!\""