From 1e1ece8f3dce8ed9958f3bd5823c135d1c19eb49 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Wed, 2 May 2018 18:02:02 +0300 Subject: Do not allow to reuse TOTP passcode (#3878) --- models/migrations/migrations.go | 2 ++ models/migrations/v62.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 models/migrations/v62.go (limited to 'models/migrations') diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 16037e1472..522086a520 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -176,6 +176,8 @@ var migrations = []Migration{ NewMigration("add is_fsck_enabled column for repos", addFsckEnabledToRepo), // v61 -> v62 NewMigration("add size column for attachments", addSizeToAttachment), + // v62 -> v63 + NewMigration("add last used passcode column for TOTP", addLastUsedPasscodeTOTP), } // Migrate database to current version diff --git a/models/migrations/v62.go b/models/migrations/v62.go new file mode 100644 index 0000000000..0c2966854b --- /dev/null +++ b/models/migrations/v62.go @@ -0,0 +1,22 @@ +// Copyright 2018 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "fmt" + + "github.com/go-xorm/xorm" +) + +func addLastUsedPasscodeTOTP(x *xorm.Engine) error { + type TwoFactor struct { + LastUsedPasscode string `xorm:"VARCHAR(10)"` + } + + if err := x.Sync2(new(TwoFactor)); err != nil { + return fmt.Errorf("Sync2: %v", err) + } + return nil +} -- cgit v1.2.3