Display error when remote repositories can't be fetched
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
891f36f6f3
commit
093c58f006
@ -27,7 +27,7 @@ const (
|
||||
var (
|
||||
gitlabClientID = ""
|
||||
gitlabSecret = ""
|
||||
gitlaboauth2Config oauth2.Config
|
||||
gitlaboauth2Config *oauth2.Config
|
||||
gitlabToken func() *oauth2.Token
|
||||
)
|
||||
|
||||
@ -41,7 +41,7 @@ func initializeGitLabOIDC(router *gin.Engine, authrouter *gin.RouterGroup, admin
|
||||
router.GET("/callback/gitlabcri/complete", GitLab_OAuth_complete)
|
||||
|
||||
if gitlabClientID != "" && gitlabSecret != "" {
|
||||
gitlaboauth2Config = oauth2.Config{
|
||||
gitlaboauth2Config = &oauth2.Config{
|
||||
ClientID: gitlabClientID,
|
||||
ClientSecret: gitlabSecret,
|
||||
RedirectURL: oidcRedirectURL + baseURL + "/callback/gitlabcri/complete",
|
||||
@ -243,6 +243,10 @@ func GitLab_GetMyRepositories(c *gin.Context) {
|
||||
}*/
|
||||
|
||||
func GitLab_getUsersRepositories(c context.Context, u *User) ([]*GitLabRepository, error) {
|
||||
if gitlaboauth2Config == nil || gitlabToken == nil {
|
||||
return nil, fmt.Errorf("the connection with GitLab is not setup yet")
|
||||
}
|
||||
|
||||
client := gitlaboauth2Config.Client(c, gitlabToken())
|
||||
|
||||
req, err := http.NewRequest("GET", gitlabBaseURL+fmt.Sprintf("/api/v4/users/%s/projects?per_page=100", u.Login), nil)
|
||||
|
@ -165,14 +165,18 @@
|
||||
{/each}
|
||||
</select>
|
||||
<label>Dépôt GitLab pour ce travail :</label>
|
||||
<button
|
||||
type="submit"
|
||||
class="mt-2 btn btn-primary"
|
||||
disable={submitInProgress || readonly || !repo_used || !repo_used.uri}
|
||||
>
|
||||
Utiliser ce dépôt
|
||||
</button>
|
||||
{:catch err}
|
||||
<div class="text-danger">
|
||||
{err.message} Veuillez réessyer dans quelques instants…<br>Si le problème persiste, contactez votre professeur.
|
||||
</div>
|
||||
{/await}
|
||||
<button
|
||||
type="submit"
|
||||
class="mt-2 btn btn-primary"
|
||||
disable={submitInProgress || readonly || !repo_used || !repo_used.uri}
|
||||
>
|
||||
Utiliser ce dépôt
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 btn btn-info"
|
||||
|
Reference in New Issue
Block a user