almost complete telegram user verification

When signing up, the user is given a pin code which they send to a
telegram bot. This provides user verification, but more importantly
allows the bot to message the user, as the Telegram API requires the
user to interact with the bot before it can do the opposite.

The bot should recognize the correct language, but a /lang command is
also provided to change it.

The verification process is pretty much functional but ui is still
broken, and it isn't properly integrated yet.
This commit is contained in:
Harvey Tindall
2021-05-07 01:08:12 +01:00
parent 0e21942cd6
commit 99875b9176
19 changed files with 598 additions and 97 deletions
+32 -2
View File
@@ -549,7 +549,7 @@ func (app *appContext) EnableDisableUsers(gc *gin.Context) {
}
if len(addresses) != 0 {
go func(reason string, addresses []string) {
var msg *Email
var msg *Message
var err error
if req.Enabled {
msg, err = app.email.constructEnabled(reason, app, false)
@@ -1580,7 +1580,7 @@ func (app *appContext) GetCustomEmailTemplate(gc *gin.Context) {
id := gc.Param("id")
var content string
var err error
var msg *Email
var msg *Message
var variables []string
var conditionals []string
var values map[string]interface{}
@@ -1874,6 +1874,36 @@ func (app *appContext) ServeLang(gc *gin.Context) {
respondBool(400, false, gc)
}
// @Summary Returns true/false on whether or not a telegram PIN was verified.
// @Produce json
// @Success 200 {object} boolResponse
// @Success 401 {object} boolResponse
// @Param pin path string true "PIN code to check"
// @Param invCode path string true "invite Code"
// @Router /invite/{invCode}/telegram/verified/{pin} [get]
// @tags Other
func (app *appContext) TelegramVerified(gc *gin.Context) {
code := gc.Param("invCode")
if _, ok := app.storage.invites[code]; !ok {
respondBool(401, false, gc)
return
}
pin := gc.Param("pin")
tokenIndex := -1
for i, v := range app.telegram.verifiedTokens {
if v == pin {
tokenIndex = i
break
}
}
if tokenIndex != -1 {
length := len(app.telegram.verifiedTokens)
app.telegram.verifiedTokens[length-1], app.telegram.verifiedTokens[tokenIndex] = app.telegram.verifiedTokens[tokenIndex], app.telegram.verifiedTokens[length-1]
app.telegram.verifiedTokens = app.telegram.verifiedTokens[:length-1]
}
respondBool(200, tokenIndex != -1, gc)
}
// @Summary Restarts the program. No response means success.
// @Router /restart [post]
// @tags Other