Add Golangci Lint (#676)
Increase golangci timeout Fix installing golangci-lint in ci Remove mage targets replaced by golangci Run golint in ci Add goheader linter Enable & fix more linters Fix lint issues Add mage target to automagically fix issues found by golangci golangci-lint run --fix Add golangci config Add golangci mage target Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/676 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -18,9 +18,10 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"code.vikunja.io/web"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.vikunja.io/web"
|
||||
)
|
||||
|
||||
// =====================
|
||||
|
@ -17,10 +17,11 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
"image"
|
||||
)
|
||||
|
||||
// TOTP holds a user's totp setting in the database.
|
||||
@ -35,7 +36,7 @@ type TOTP struct {
|
||||
}
|
||||
|
||||
// TableName holds the table name for totp secrets
|
||||
func (T *TOTP) TableName() string {
|
||||
func (t *TOTP) TableName() string {
|
||||
return "totp"
|
||||
}
|
||||
|
||||
|
@ -18,17 +18,19 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/mail"
|
||||
"code.vikunja.io/api/pkg/metrics"
|
||||
"code.vikunja.io/api/pkg/utils"
|
||||
"code.vikunja.io/web"
|
||||
"fmt"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/labstack/echo/v4"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Login Object to recive user credentials in JSON format
|
||||
@ -189,7 +191,7 @@ func CheckUserCredentials(u *Login) (*User, error) {
|
||||
func CheckUserPassword(user *User, password string) error {
|
||||
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
||||
if err != nil {
|
||||
if err == bcrypt.ErrMismatchedHashAndPassword {
|
||||
if errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) {
|
||||
return ErrWrongUsernameOrPassword{}
|
||||
}
|
||||
return err
|
||||
@ -322,7 +324,6 @@ func UpdateUser(user *User) (updatedUser *User, err error) {
|
||||
|
||||
// Check if we have at least a username
|
||||
if user.Username == "" {
|
||||
//return User{}, ErrNoUsername{user.ID}
|
||||
user.Username = theUser.Username // Dont change the username if we dont have one
|
||||
} else {
|
||||
// Check if the new username already exists
|
||||
|
@ -18,8 +18,9 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"testing"
|
||||
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
)
|
||||
|
||||
func TestUserEmailConfirm(t *testing.T) {
|
||||
|
@ -18,9 +18,10 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user