1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Rename tokens.Edit to Extend.

This commit is contained in:
Juliusz Chroboczek 2024-04-14 13:12:19 +02:00
parent 31f89163a2
commit 68887f13d5
3 changed files with 8 additions and 8 deletions

View file

@ -1793,7 +1793,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
if tok.Expires == nil { if tok.Expires == nil {
return terror("error", "trying to edit nothing") return terror("error", "trying to edit nothing")
} }
new, err := token.Edit( new, err := token.Extend(
c.group.Name(), tok.Token, *tok.Expires, c.group.Name(), tok.Token, *tok.Expires,
) )
if err != nil { if err != nil {

View file

@ -217,18 +217,18 @@ func Add(token *Stateful) (*Stateful, error) {
return tokens.Add(token) return tokens.Add(token)
} }
func Edit(group, token string, expires time.Time) (*Stateful, error) { func Extend(group, token string, expires time.Time) (*Stateful, error) {
return tokens.Edit(group, token, expires) return tokens.Extend(group, token, expires)
} }
func (state *state) Edit(group, token string, expires time.Time) (*Stateful, error) { func (state *state) Extend(group, token string, expires time.Time) (*Stateful, error) {
tokens.mu.Lock() tokens.mu.Lock()
defer tokens.mu.Unlock() defer tokens.mu.Unlock()
return state.edit(group, token, expires) return state.extend(group, token, expires)
} }
// called locked // called locked
func (state *state) edit(group, token string, expires time.Time) (*Stateful, error) { func (state *state) extend(group, token string, expires time.Time) (*Stateful, error) {
err := state.load() err := state.load()
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -269,11 +269,11 @@ func TestTokenStorage(t *testing.T) {
} }
expectTokens(t, s.tokens, tokens) expectTokens(t, s.tokens, tokens)
_, err = s.Edit("test2", tokens[1].Token, now.Add(time.Hour)) _, err = s.Extend("test2", tokens[1].Token, now.Add(time.Hour))
if err == nil { if err == nil {
t.Errorf("Edit succeeded with wrong group") t.Errorf("Edit succeeded with wrong group")
} }
new, err := s.Edit("test", tokens[1].Token, now.Add(time.Hour)) new, err := s.Extend("test", tokens[1].Token, now.Add(time.Hour))
if err != nil { if err != nil {
t.Errorf("Edit: %v", err) t.Errorf("Edit: %v", err)
} }