19 lines
388 B
Go
19 lines
388 B
Go
package invite
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// returns the email allowed for this invite
|
|
func (i *InviteKV) Redeem(given_url string) (string, bool) {
|
|
// check URL
|
|
opaque := strings.Split(given_url, i.URL)[1]
|
|
potential, exists := i.store.Get(opaque)
|
|
if !exists {
|
|
return "", false
|
|
}
|
|
potential.Redeemed = time.Now()
|
|
i.store.Set(opaque, potential)
|
|
return potential.Email, true
|
|
}
|