From 4f99fc339fbc641ac2c8713a530f8f429328b9d5 Mon Sep 17 00:00:00 2001 From: Annie Elequin Date: Fri, 17 Sep 2021 16:06:16 -0400 Subject: [PATCH] maybe add login in the provisioning call --- commands.go | 2 +- provisioning.go | 16 ++++++++++++++-- user.go | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/commands.go b/commands.go index 2089141..f347e0f 100644 --- a/commands.go +++ b/commands.go @@ -390,7 +390,7 @@ func (handler *CommandHandler) CommandLogin(ce *CommandEvent) { ce.User.Login(ce) } -const cmdLogoutHelp = `logout - Logout from WhatsApp` +const cmdLogoutHelp = `logout - Logout from GroupMe` // CommandLogout handles !logout command func (handler *CommandHandler) CommandLogout(ce *CommandEvent) { diff --git a/provisioning.go b/provisioning.go index 83995c0..1523e00 100644 --- a/provisioning.go +++ b/provisioning.go @@ -336,8 +336,20 @@ var upgrader = websocket.Upgrader{ } func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) { - // userID := r.URL.Query().Get("user_id") - // user := prov.bridge.GetUserByMXID(id.UserID(userID)) + userID := r.URL.Query().Get("user_id") + user := prov.bridge.GetUserByMXID(id.UserID(userID)) + + if len(ce.Args) < 1 { + // Return error that the token needs to be longer than 0 length + // ce.Reply(`Get your access token from https://dev.groupme.com/ which should be the first argument to login`) + return + } + user.Token = ce.Args[0] + + user.addToJIDMap() + // ce.Reply("Successfully logged in, synchronizing chats...") + user.PostLogin() + user.Connect() // c, err := upgrader.Upgrade(w, r, nil) // if err != nil { diff --git a/user.go b/user.go index 0e589a7..6ddc22e 100644 --- a/user.go +++ b/user.go @@ -363,6 +363,7 @@ func (user *User) Login(ce *CommandEvent) { // // Also between the two logout methods (commands.go and provisioning.go) // user.ConnectionErrors = 0 // user.JID = strings.Replace(user.Conn.Info.Wid, whatsappExt.OldUserSuffix, whatsappExt.NewUserSuffix, 1) + if len(ce.Args) < 1 { ce.Reply(`Get your access token from https://dev.groupme.com/ which should be the first argument to login`) return