{"record":{"id":"e95763e34cea9dcb","repo":"v2rayA/v2rayA","slug":"wrong-username-or-password","errorCode":null,"errorMessage":"wrong username or password","messagePattern":"wrong username or password","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/server/service/account.go","lineNumber":14,"sourceCode":"package service\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/v2rayA/v2rayA/common\"\n\t\"github.com/v2rayA/v2rayA/db/configure\"\n\t\"github.com/v2rayA/v2rayA/pkg/server/jwt\"\n)\n\nfunc Login(username, password string) (token string, err error) {\n\tif !IsValidAccount(username, password) {\n\t\treturn \"\", fmt.Errorf(\"wrong username or password\")\n\t}\n\tdur := 30 * 24 * time.Hour\n\treturn jwt.MakeJWT(map[string]string{\n\t\t\"uname\": username,\n\t}, &dur)\n}\n\nfunc IsValidAccount(username, password string) bool {\n\tpwd, err := configure.GetPasswordOfAccount(username)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn common.CheckPassword(password, pwd)\n}\n\nfunc Register(username, password string) (token string, err error) {\n\tif configure.ExistsAccount(username) {\n\t\treturn \"\", fmt.Errorf(\"username exists\")","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/server/service/account.go#L1-L32","documentation":"Login validates credentials with IsValidAccount(username, password); if the check fails it returns the fixed message 'wrong username or password'. This is a deliberate generic error so it does not reveal whether the username or the password was wrong.","triggerScenarios":"POSTing to the login endpoint with a username that has no account in configure's account store, or with a password whose hashed value does not match the stored CryptoPwd hash.","commonSituations":"Typo in either field; account registered in a different config directory (wrong --v2raya-confdir so the db has no such user); password changed elsewhere; case/whitespace differences in username.","solutions":["Re-enter credentials carefully, checking case and whitespace","If the account was never created, register first (PostAccount) before logging in","Confirm v2rayA is pointed at the config directory that actually holds the account","If the password is lost, delete/recreate the account in the config db"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if username == \"\" || password == \"\" {\n  return errors.New(\"username and password are required\")\n}","typeGuard":null,"tryCatchPattern":"token, err := service.Login(user, pass)\nif err != nil && err.Error() == \"wrong username or password\" {\n  // show generic auth-failure message, do not leak which field failed\n  return err\n}","preventionTips":["Register the account before attempting login","Verify the correct --v2raya-confdir so the right account db is used","Trim whitespace and respect case in usernames","Use a password manager to avoid typos"],"tags":["auth","login","credentials"],"backgroundTag":"invalid-credentials","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}