Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add remember me checkbox back (#1397)

I tried locally and I'm kept logged in. @ewhal check after update that you do have the same hash set in both nyaa and sukebei. If you do, just change the domain name (".pantsu.cat") in the functions getDomainName() to the subdomain. Because I don't see why it wouldn't work otherwise
Cette révision appartient à :
akuma06 2017-08-26 04:57:02 +02:00 révisé par ewhal
Parent 9f2f978660
révision 53ba669ba6
6 fichiers modifiés avec 18 ajouts et 12 suppressions

Voir le fichier

@ -13,13 +13,10 @@
{{ yield errors(name="Username")}}
<input type="password" name="password" id="password" class="form-input up-input" placeholder="{{ T("password")}}"/>
<br/>
<input type="hidden" name="redirectTo" value="{{ Form.RedirectTo }}"/>
{{ yield errors(name="Password")}}
<!-- <span class="button-checkbox">
<button type="button" class="btn hidden" data-color="info">{{ T("remember_me")}}</button>
<input type="checkbox" name="remember_me" id="remember_me" checked="checked">
<a href="" class="btn btn-link pull-right">{{ T("forgot_password")}}</a>
</span> -->
<input type="hidden" name="redirectTo" value="{{ Form.RedirectTo }}"/>
<input type="checkbox" name="remember_me" id="remember_me" value="remember" checked="checked"><label class="input-label" for="remember_me">{{ T("remember_me") }}</label><br><br>
<input type="submit" class="form-input" value="{{ T("signin")}}"/>
<a href="/register" class="btn btn-lg btn-primary btn-block">{{ T("register")}}</a>
</form>

Voir le fichier

@ -61,7 +61,7 @@ func walkDirTest(dir string, t *testing.T) {
fakeDB := &models.DatabaseDump{time.Now(), 3, "test", "test"}
fakeLanguage := &publicSettings.Language{"English", "en", "en-us"}
fakeTorrentRequest := &torrentValidator.TorrentRequest{Name: "test", Magnet: "", Category: "", Remake: false, Description: "", Status: 1, Hidden: false, CaptchaID: "", WebsiteLink: "", SubCategory: 0, Languages: nil, Infohash: "", SubCategoryID: 0, CategoryID: 0, Filesize: 0, Filepath: "", FileList: nil, Trackers: nil, Tags: torrentValidator.TagsRequest{}}
fakeLogin := &userValidator.LoginForm{"test", "test", "/"}
fakeLogin := &userValidator.LoginForm{"test", "test", "/", "false"}
fakeRegistration := &userValidator.RegistrationForm{"test", "", "test", "test", "xxxx", "1"}
fakeReport := &models.TorrentReport{1, "test", 1, 1, time.Now(), fakeTorrent, fakeUser}
fakeOauthForm := apiValidator.CreateForm{"", "f", []string{fu}, []string{}, []string{}, "", "fedr", fu, fu, fu, fu, []string{em}, ""}

Voir le fichier

@ -1,6 +1,8 @@
package cookies
import "github.com/NyaaPantsu/nyaa/config"
import (
"github.com/NyaaPantsu/nyaa/config"
)
func getDomainName() string {
domain := config.Get().Cookies.DomainName
@ -10,6 +12,9 @@ func getDomainName() string {
return domain
}
func getMaxAge() int {
func getMaxAge(rememberMe bool) int {
if rememberMe {
return 365 * 24 * 3600
}
return config.Get().Cookies.MaxAge
}

Voir le fichier

@ -101,7 +101,10 @@ func Clear(c *gin.Context) {
// SetLogin sets the authentication cookie
func SetLogin(c *gin.Context, user *models.User) (int, error) {
maxAge := getMaxAge()
maxAge := getMaxAge(false)
if c.PostForm("remember_me") == "remember" {
maxAge = getMaxAge(true)
}
validUntil := timeHelper.FewDurationLater(time.Duration(maxAge) * time.Second)
encoded, err := Encode(user.ID, validUntil)
if err != nil {

Voir le fichier

@ -14,7 +14,8 @@ type RegistrationForm struct {
type LoginForm struct {
Username string `validate:"required" json:"username" form:"username"`
Password string `validate:"required" json:"password" form:"password"`
RedirectTo string `validate:"-" form:"redirectTo" json:"omitempty"`
RedirectTo string `validate:"-" form:"redirectTo" json:"-"`
RememberMe string `validate:"-" form:"remember_me" json:"-"`
}
// UserForm is used when updating a user.

Voir le fichier

@ -35,7 +35,7 @@ func TestForms(t *testing.T) {
registration := &RegistrationForm{
"lol", "", "testing", "testing", "xxx", "1",
}
login := &LoginForm{"lol", "testing", "/"}
login := &LoginForm{"lol", "testing", "/", "false"}
user := &UserForm{"lol", "", "", "testing", "testing", "testing", 0, ""}
userSettings := &UserSettingsForm{}
password := &PasswordForm{"testing", "testing"}