mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-31 10:20:55 +00:00
[BREAKING] Add tests for username auth, fix form key names
Also, testing infrastructure
This commit is contained in:
parent
26747a1104
commit
c0500457a6
4 changed files with 252 additions and 22 deletions
|
@ -4,13 +4,13 @@ import (
|
|||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
irc "github.com/fluffle/goirc/client"
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type AuthCallback func(client *ClientInfo, successful bool)
|
||||
|
@ -106,13 +106,11 @@ func ircConnection() {
|
|||
channel := line.Args[0]
|
||||
msg := line.Args[1]
|
||||
if channel != AuthChannel || !strings.HasPrefix(msg, AuthCommand) || !line.Public() {
|
||||
fmt.Println(DEBUG, "discarded msg", line.Raw)
|
||||
return
|
||||
}
|
||||
|
||||
msgArray := strings.Split(msg, " ")
|
||||
if len(msgArray) != 2 {
|
||||
fmt.Println(DEBUG, "discarded msg - not 2 strings", line.Raw)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -129,7 +127,7 @@ func ircConnection() {
|
|||
|
||||
}
|
||||
|
||||
func submitAuth(user, challenge string) error {
|
||||
func submitAuth(user, challenge string) {
|
||||
var auth PendingAuthorization
|
||||
var idx int = -1
|
||||
|
||||
|
@ -147,12 +145,11 @@ func submitAuth(user, challenge string) error {
|
|||
PendingAuthLock.Unlock()
|
||||
|
||||
if idx == -1 {
|
||||
return errChallengeNotFound // perhaps it was for another socket server
|
||||
return // perhaps it was for another socket server
|
||||
}
|
||||
|
||||
// auth is valid, and removed from pending list
|
||||
|
||||
fmt.Println(DEBUG, "authorization success for user", auth.Client.TwitchUsername)
|
||||
var usernameChanged bool
|
||||
auth.Client.Mutex.Lock()
|
||||
if auth.Client.TwitchUsername == user { // recheck condition
|
||||
|
@ -169,4 +166,4 @@ func submitAuth(user, challenge string) error {
|
|||
auth.Callback(auth.Client, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue