Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
PHP
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
ARISE
AriseID Connect
Exemples
PHP
Validations
d80c82a1
Valider
d80c82a1
rédigé
6 years ago
par
Aaron Parecki
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
match book formatting
parent
c822eb9b
Loading
Loading
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
github.php
+16
-11
16 ajouts, 11 suppressions
github.php
avec
16 ajouts
et
11 suppressions
github.php
+
16
−
11
Voir le fichier @
d80c82a1
...
...
@@ -19,7 +19,8 @@ $baseURL = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
session_start
();
// Start the login process by sending the user to Github's authorization page
// Start the login process by sending the user
// to Github's authorization page
if
(
isset
(
$_GET
[
'action'
])
&&
$_GET
[
'action'
]
==
'login'
)
{
unset
(
$_SESSION
[
'access_token'
]);
...
...
@@ -33,22 +34,26 @@ if(isset($_GET['action']) && $_GET['action'] == 'login') {
'scope'
=>
'user public_repo'
,
'state'
=>
$_SESSION
[
'state'
]
);
// Redirect the user to Github's authorization page
header
(
'Location: '
.
$authorizeURL
.
'?'
.
http_build_query
(
$params
));
header
(
'Location: '
.
$authorizeURL
.
'?'
.
http_build_query
(
$params
));
die
();
}
if
(
isset
(
$_GET
[
'action'
])
&&
$_GET
[
'action'
]
==
'logout'
)
{
unset
(
$_SESSION
[
'access_token'
]);
header
(
'Location: '
.
$baseURL
);
die
();
}
// When Github redirects the user back here,
there will be a "code" and "state"
// parameter in the query string
// When Github redirects the user back here,
//
there will be a "code" and "state"
parameter in the query string
if
(
isset
(
$_GET
[
'code'
]))
{
// Verify the state matches our stored state
if
(
!
isset
(
$_GET
[
'state'
])
||
$_SESSION
[
'state'
]
!=
$_GET
[
'state'
])
{
if
(
!
isset
(
$_GET
[
'state'
])
||
$_SESSION
[
'state'
]
!=
$_GET
[
'state'
])
{
header
(
'Location: '
.
$baseURL
.
'?error=invalid_state'
);
die
();
}
...
...
@@ -61,14 +66,14 @@ if(isset($_GET['code'])) {
'redirect_uri'
=>
$baseURL
,
'code'
=>
$_GET
[
'code'
]
));
$_SESSION
[
'access_token'
]
=
$token
[
'access_token'
];
header
(
'Location: '
.
$baseURL
);
die
();
}
if
(
isset
(
$_GET
[
'action'
])
&&
$_GET
[
'action'
]
==
'repos'
)
{
if
(
isset
(
$_GET
[
'action'
])
&&
$_GET
[
'action'
]
==
'repos'
)
{
// Find all repos created by the authenticated user
$repos
=
apiRequest
(
$apiURLBase
.
'user/repos?'
.
http_build_query
([
'sort'
=>
'created'
,
...
...
@@ -77,14 +82,14 @@ if(isset($_GET['action']) && $_GET['action'] == 'repos') {
echo
'<ul>'
;
foreach
(
$repos
as
$repo
)
{
echo
'<li><a href="'
.
$repo
[
'html_url'
]
.
'">'
.
$repo
[
'name'
]
.
'</a></li>'
;
echo
'<li><a href="'
.
$repo
[
'html_url'
]
.
'">'
.
$repo
[
'name'
]
.
'</a></li>'
;
}
echo
'</ul>'
;
die
();
}
// If there is an access token in the session, the user is logged in
// If there is an access token in the session
// the user is already logged in
if
(
!
isset
(
$_GET
[
'action'
]))
{
if
(
!
empty
(
$_SESSION
[
'access_token'
]))
{
echo
'<h3>Logged In</h3>'
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter