+
@@ -87,11 +89,13 @@
import { API_URL } from "@/resources.js";
import UserBubble from "@/components/UserBubble.vue";
import { getUserInfo } from "@/server_fetch_utils.js";
+import GetEmailModal from "@/components/GetEmailModal.vue";
export default {
data() {
return {
isLoginDropdownVisible: false,
isUserDropdownVisible: false,
+ emailModalIsOpen: false,
apiUrl: API_URL,
currentUser: null,
currentUserInfo: {},
@@ -99,22 +103,16 @@ export default {
},
components: {
UserBubble,
- },
- props: {
- modelValue: Boolean,
- },
- watch: {
- modelValue(newValue) {
- if (newValue) {
- this.openModal();
- }
- if (!newValue) {
- this.closeModal();
- }
- },
+ GetEmailModal,
},
methods: {
async getUser() {
+ // Need to reload the page if this is a magic-link login
+ let token = this.$route.query.token;
+ if (token != null) {
+ window.location.href = this.apiUrl + "/login/email?token=" + token;
+ }
+
let user = await getUserInfo();
if (user != null) {
this.currentUser = user.display_name;
diff --git a/webapp/src/server_fetch_utils.js b/webapp/src/server_fetch_utils.js
index 7e6e49057..95866703e 100644
--- a/webapp/src/server_fetch_utils.js
+++ b/webapp/src/server_fetch_utils.js
@@ -258,6 +258,19 @@ export async function getUserInfo() {
});
}
+export async function requestMagicLink(email_address) {
+ return fetch_post(`${API_URL}/login/magic-link`, {
+ email: email_address,
+ referrer: window.location.origin,
+ })
+ .then((response_json) => {
+ return response_json;
+ })
+ .catch((err) => {
+ return err;
+ });
+}
+
export function searchUsers(query, nresults = 100) {
// construct a url with parameters:
var url = new URL(`${API_URL}/search-users/`);