diff --git a/canapGEST/API/app/Helpers/AccessLevelHelper.php b/canapGEST/API/app/Helpers/AccessLevelHelper.php index ca00e43c6db476c6b5aeeeb587eb7e5bb2fbb755..3e393294b42028131a7d1765330b39ba3a7fbda7 100644 --- a/canapGEST/API/app/Helpers/AccessLevelHelper.php +++ b/canapGEST/API/app/Helpers/AccessLevelHelper.php @@ -71,7 +71,7 @@ class AccessLevelHelper public static function isResponsible($user_groups) { - // $responsible_default_group = 'apprentis-informaticiens'; + // $responsible_default_group = 'canap-gest-users-dev'; $responsible_default_group = 'responsables-apprentis'; return in_array($responsible_default_group, $user_groups); } diff --git a/canapGEST/API/app/Http/Controllers/AuthController.php b/canapGEST/API/app/Http/Controllers/AuthController.php index 35d9b35cfc1be0abb4f163e6f8d78005b70c61ab..c6413c17c5af0a828dc5996007c1dd1d1b1a1a2d 100644 --- a/canapGEST/API/app/Http/Controllers/AuthController.php +++ b/canapGEST/API/app/Http/Controllers/AuthController.php @@ -73,8 +73,8 @@ class AuthController extends Controller public function tequilareturn() { - return redirect()->to("https://canap-gest-dev.local:8080/#/?key=" . $_GET["key"]); - // return redirect()->to("https://canap-gest:8443/#/?key=" . $_GET["key"]); + // return redirect()->to("https://canap-gest-dev.local:8080/#/?key=" . $_GET["key"]); + return redirect()->to("https://canap-gest:8443/#/?key=" . $_GET["key"]); } public function logout() diff --git a/canapGEST/API/app/Http/Controllers/MailsController.php b/canapGEST/API/app/Http/Controllers/MailsController.php index 475b7c5e3088676f76afc7a0e70427785be30bd6..9363f47778862059bc05318a1e2de3677720de91 100644 --- a/canapGEST/API/app/Http/Controllers/MailsController.php +++ b/canapGEST/API/app/Http/Controllers/MailsController.php @@ -18,25 +18,16 @@ class MailsController extends Controller public function mailApplicant() { - // TODO: mail to an applicant - echo $this->request->input('recipient'); - echo $this->request->input('from'); - echo $this->request->input('copy'); - echo $this->request->input('subject'); - echo $this->request->input('content'); - - // 'EPFL: Votre candidature pour un apprentissage'; - - $subject = $this->request->input('subject'); - $message = $this->request->input('content'); - $headers = array( // 'Content-Type' => 'text/html', // 'charset'=>'UTF8', - 'From' => 'noreply+test@epfl.ch', - 'Reply-To' => 'noreply+test@epfl.ch', + 'From' => 'noreply+candidatureApprentis@epfl.ch', + 'Reply-To' => 'noreply+candidatureApprentis@epfl.ch', 'X-Mailer' => 'PHP/' . phpversion() ); - mail($to, $subject, $message, $headers); + + foreach ($this->request->input('recipients') as $recipient) { + mail($recipient, $this->request->input('subject'), $this->request->input('content'), $headers); + } } } \ No newline at end of file diff --git a/canapGEST/API/app/Providers/TequilaClient.php b/canapGEST/API/app/Providers/TequilaClient.php index c44557a9c98de21598373cad6435f95231a9edff..950c7d9480a7904c3c62f3c5e724cf76700efcf1 100644 --- a/canapGEST/API/app/Providers/TequilaClient.php +++ b/canapGEST/API/app/Providers/TequilaClient.php @@ -43,7 +43,6 @@ class TequilaClient { // Const var $EPFL_CA = "quovadis.pem"; - var $TEQUILA_CREATE = 'createrequest'; var $TEQUILA_VALIDATE = 'validatekey'; var $TEQUILA_REDIRECT = 'requestauth'; diff --git a/canapGEST/Site/package-lock.json b/canapGEST/Site/package-lock.json index 006ad353b5f0924f57dd95c9f77dbca03f3a5345..64d59f57847b7a6500b82f968038505f61da20ef 100644 --- a/canapGEST/Site/package-lock.json +++ b/canapGEST/Site/package-lock.json @@ -1945,12 +1945,40 @@ "dev": true }, "axios": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", - "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", + "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", "requires": { - "follow-redirects": "^1.3.0", - "is-buffer": "^1.1.5" + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } } }, "babel-code-frame": { @@ -3565,6 +3593,7 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, "requires": { "ms": "^2.1.1" } @@ -4936,6 +4965,7 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", + "dev": true, "requires": { "debug": "^3.2.6" } @@ -6349,7 +6379,8 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true }, "is-callable": { "version": "1.1.4", @@ -7288,7 +7319,8 @@ "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true }, "multicast-dns": { "version": "6.2.3", diff --git a/canapGEST/Site/package.json b/canapGEST/Site/package.json index 4405c5facabcb0f26945434aa2ad47058fe22987..8d912cd39f3396b357549f3fd5d4698eaeae848b 100644 --- a/canapGEST/Site/package.json +++ b/canapGEST/Site/package.json @@ -8,7 +8,7 @@ "lint": "vue-cli-service lint" }, "dependencies": { - "axios": "^0.18.0", + "axios": "^0.18.1", "vue": "^2.6.6", "vue-router": "^3.0.1", "vuetify": "^1.5.5", diff --git a/canapGEST/Site/src/components/application/mailDialog.vue b/canapGEST/Site/src/components/application/mailDialog.vue index 8e94870e589f2d2267d783514183a8c7972c5203..e7dd5550fdb46957bea0842606256b07dc11e7c2 100644 --- a/canapGEST/Site/src/components/application/mailDialog.vue +++ b/canapGEST/Site/src/components/application/mailDialog.vue @@ -7,31 +7,26 @@ <v-card-text> <v-container grid-list-md> <v-flex xs12> - <v-text-field label="Destinataires" readonly></v-text-field> + <v-text-field label="Destinataires" :value="recipientsFormat" readonly></v-text-field> </v-flex> <v-flex xs12> - <v-text-field label="Copie"></v-text-field> - </v-flex> - <v-flex xs12> - <v-textarea label="Contenu" required></v-textarea> + <v-text-field label="Sujet" :value="mail.subject"></v-text-field> </v-flex> <v-layout wrap> <v-flex xs12 sm6> - <v-select - :items="['Refus', 'Dossier incomplet']" - label="Type de réponse" - required - ></v-select> + <v-select :items="['Refus', 'Dossier incomplet']" label="Type de réponse" required></v-select> </v-flex> </v-layout> + <v-flex xs12> + <v-textarea label="Contenu" v-model="mail.content" required></v-textarea> + </v-flex> </v-container> </v-card-text> <v-card-actions> <v-spacer></v-spacer> <v-btn color="red" flat @click="is_open = false">Annuler</v-btn> - <v-btn color="green" flat @click="is_open = false">Envoyer</v-btn> + <v-btn color="green" flat @click="sendMails">Envoyer</v-btn> </v-card-actions> - {{to}} </v-card> </v-dialog> </template> @@ -48,22 +43,30 @@ export default { this.is_open = this.opened if (!this.is_open) { this.$emit('closed') + } else { + this.mail.to = this.to.map(a => a.applicant_mail) } } }, - created () { - // Get emails - console.log(this.to) - // console.log(this.to.arr.find(o => o.applicant_mail)) - }, data () { return { is_open: false, mail: { to: '', + subject: 'EPFL: Votre candidature', content: '' } } + }, + computed: { + recipientsFormat () { + return this.mail.to.length > 1 ? this.mail.to[0] + ' et ' + (this.mail.to.length - 1) + ' autre(s)' : this.mail.to[0] + } + }, + methods: { + sendMails () { + this.$store.dispatch('moduleApplications/sendMails', this.mail).then(this.is_open = false) + } } } </script> diff --git a/canapGEST/Site/src/store/modules/applications/actions.js b/canapGEST/Site/src/store/modules/applications/actions.js index 5fc9e1a2442add969fb84b347cc1aa887ca15293..e7e9c75097657b2e5a69020696a3af3acd961665 100644 --- a/canapGEST/Site/src/store/modules/applications/actions.js +++ b/canapGEST/Site/src/store/modules/applications/actions.js @@ -207,4 +207,19 @@ export function updateComment (context, data) { .then(response => { context.commit('moduleSnackbar/toggle', { open: true, message: response.data.message, type: 'success' }, { root: true }) }) +} + +export function sendMails (context, data) { + return axios({ + method: 'post', + url: '/mail/applicant', + data: { + recipients: data.to, + subject: data.subject, + content: data.content + } + }) + .then(() => { + context.commit('moduleSnackbar/toggle', { open: true, message: 'Mails envoyés', type: 'success' }, { root: true }) + }) } \ No newline at end of file