1

如何修复:AtlassianHostUser 在 Jira 云插件中为空。

我的控制器看起来像这样

@Controller
@IgnoreJwt
public class MainController {

private final StorageService storageService;

@Autowired
public MainController(StorageService storageService) {
    this.storageService = storageService;
}
.
.
.
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public String handleFileUpload(@AuthenticationPrincipal 
AtlassianHostUser hostUser,
@RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) {

hostUser.getUserKey(); // Causing NPE because hostUser is null
}

我的描述符如下所示

{
"key": "copy-paste-plugin",
"baseUrl": "${addon.base-url}",
"name": "Copy Paste (Spring Boot)",
"authentication": {
    "type": "jwt"
},
"lifecycle": {
    "installed": "/installed",
    "uninstalled": "/uninstalled"
},
"scopes": [
    "READ",
    "ACT_AS_USER"
],

"modules": {
    "generalPages": [
        {
            "url": "/upload",
            "key": "upload",
            "location": "none",
            "name": {
                "value": "Attach a file"
            },
            "conditions": [
                {
                    "condition": "user_is_logged_in"
                }
            ]
        }
    ]
}
}

这是 Jira 云插件。我不确定我错过了哪一部分。寻找你的帮助/指针。

谢谢!

4

0 回答 0