|
@@ -19,6 +19,7 @@ import (
|
19
|
19
|
const (
|
20
|
20
|
keyAccountExists = "account %s exists"
|
21
|
21
|
keyAccountVerified = "account %s verified"
|
|
22
|
+ keyAccountName = "account %s name" // stores the 'preferred name' of the account, casemapped appropriately
|
22
|
23
|
keyAccountRegTime = "account %s registered.time"
|
23
|
24
|
keyAccountCredentials = "account %s credentials"
|
24
|
25
|
)
|
|
@@ -94,6 +95,7 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo
|
94
|
95
|
|
95
|
96
|
// get and sanitise account name
|
96
|
97
|
account := NewName(msg.Params[1])
|
|
98
|
+ //TODO(dan): probably don't need explicit check for "*" here... until we actually casemap properly as per rfc7700
|
97
|
99
|
if !account.IsNickname() || msg.Params[1] == "*" {
|
98
|
100
|
client.Send(nil, server.nameString, ERR_REG_UNSPECIFIED_ERROR, client.nickString, msg.Params[1], "Account name is not valid")
|
99
|
101
|
return false
|
|
@@ -115,6 +117,7 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo
|
115
|
117
|
registeredTimeKey := fmt.Sprintf(keyAccountRegTime, accountString)
|
116
|
118
|
|
117
|
119
|
tx.Set(accountKey, "1", nil)
|
|
120
|
+ tx.Set(fmt.Sprintf(keyAccountName, accountString), strings.TrimSpace(msg.Params[1]), nil)
|
118
|
121
|
tx.Set(registeredTimeKey, strconv.FormatInt(time.Now().Unix(), 10), nil)
|
119
|
122
|
return nil
|
120
|
123
|
})
|
|
@@ -230,6 +233,20 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo
|
230
|
233
|
if callbackNamespace == "*" {
|
231
|
234
|
err = server.store.Update(func(tx *buntdb.Tx) error {
|
232
|
235
|
tx.Set(keyAccountVerified, "1", nil)
|
|
236
|
+
|
|
237
|
+ // load acct info inside store tx
|
|
238
|
+ account := ClientAccount{
|
|
239
|
+ Name: strings.TrimSpace(msg.Params[1]),
|
|
240
|
+ RegisteredAt: time.Now(),
|
|
241
|
+ Clients: []*Client{client},
|
|
242
|
+ }
|
|
243
|
+ //TODO(dan): Consider creating ircd-wide account adding/removing/affecting lock for protecting access to these sorts of variables
|
|
244
|
+ server.accounts[accountString] = &account
|
|
245
|
+ client.account = &account
|
|
246
|
+
|
|
247
|
+ client.Send(nil, server.nameString, RPL_REGISTRATION_SUCCESS, client.nickString, accountString, "Account created")
|
|
248
|
+ client.Send(nil, server.nameString, RPL_LOGGEDIN, client.nickString, client.nickMaskString, accountString, fmt.Sprintf("You are now logged in as %s", accountString))
|
|
249
|
+ client.Send(nil, server.nameString, RPL_SASLSUCCESS, client.nickString, "Authentication successful")
|
233
|
250
|
return nil
|
234
|
251
|
})
|
235
|
252
|
if err != nil {
|
|
@@ -239,7 +256,6 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo
|
239
|
256
|
return false
|
240
|
257
|
}
|
241
|
258
|
|
242
|
|
- client.Notice("Account creation was successful!")
|
243
|
259
|
return false
|
244
|
260
|
}
|
245
|
261
|
|