From 0bd86baf4d6b10f111c1da0492a1fa8ef71c52c4 Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Mon, 14 Feb 2022 22:58:13 +0800 Subject: [PATCH] Fix crash in incremental ID. --- controllers/account.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/controllers/account.go b/controllers/account.go index 17f83bb6..a7710b9a 100644 --- a/controllers/account.go +++ b/controllers/account.go @@ -145,7 +145,12 @@ func (c *ApiController) Signup() { id := util.GenerateId() if application.GetSignupItemRule("ID") == "Incremental" { lastUser := object.GetLastUser(form.Organization) - lastIdInt := util.ParseInt(lastUser.Id) + + lastIdInt := -1 + if lastUser != nil { + lastIdInt = util.ParseInt(lastUser.Id) + } + id = strconv.Itoa(lastIdInt + 1) }