kopia lustrzana https://github.com/bugout-dev/moonstream
				
				
				
			Got user login functional using Moonstream application on Brood
							rodzic
							
								
									12e3d576eb
								
							
						
					
					
						commit
						30d905b68f
					
				| 
						 | 
				
			
			@ -82,7 +82,7 @@ const EntriesNavigation = () => {
 | 
			
		|||
      );
 | 
			
		||||
      _setNewFilterState(props);
 | 
			
		||||
    },
 | 
			
		||||
    [subscriptionsCache.data.subscriptions]
 | 
			
		||||
    [subscriptionsCache?.data?.subscriptions]
 | 
			
		||||
  );
 | 
			
		||||
  const loadMoreButtonRef = useRef(null);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ const useLogin = (loginType) => {
 | 
			
		|||
        if (!data) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        localStorage.setItem("MOONSTREAM_ACCESS_TOKEN", data.data.access_token);
 | 
			
		||||
        localStorage.setItem("MOONSTREAM_ACCESS_TOKEN", data.data.id);
 | 
			
		||||
        const invite_code = window.sessionStorage.getItem("invite_code");
 | 
			
		||||
        if (invite_code) {
 | 
			
		||||
          inviteAccept(invite_code);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
export const AUTH_URL = process.env.NEXT_PUBLIC_SIMIOTICS_AUTH_URL;
 | 
			
		||||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import React, { useState, useEffect, useCallback } from "react";
 | 
			
		||||
import http from "axios";
 | 
			
		||||
import { AUTH_URL } from "./constants";
 | 
			
		||||
import UserContext from "./context";
 | 
			
		||||
import { AUTH_URL } from "../../services/auth.service";
 | 
			
		||||
 | 
			
		||||
const UserProvider = ({ children }) => {
 | 
			
		||||
  const [user, setUser] = useState();
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ const UserProvider = ({ children }) => {
 | 
			
		|||
 | 
			
		||||
    const headers = { Authorization: `Bearer ${token}` };
 | 
			
		||||
    http
 | 
			
		||||
      .get(`${AUTH_URL}/user`, { headers })
 | 
			
		||||
      .get(`${AUTH_URL}/`, { headers })
 | 
			
		||||
      .then((response) => {
 | 
			
		||||
        setUser(response.data);
 | 
			
		||||
      })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import { http } from "../utils";
 | 
			
		||||
 | 
			
		||||
const API_URL = process.env.NEXT_PUBLIC_MOONSTREAM_API_URL;
 | 
			
		||||
const AUTH_URL = `${API_URL}/users`;
 | 
			
		||||
export const AUTH_URL = `${API_URL}/users`;
 | 
			
		||||
 | 
			
		||||
export const login = ({ username, password }) => {
 | 
			
		||||
  const data = new FormData();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,6 @@ import * as GroupService from "./group.service";
 | 
			
		|||
import * as PreferencesService from "./preferences.service";
 | 
			
		||||
import * as HumbugService from "./humbug.service";
 | 
			
		||||
import * as InvitesService from "./invites.service";
 | 
			
		||||
import * as UserService from "./user.service";
 | 
			
		||||
import * as SubscriptionsService from "./subscriptions.service";
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +19,5 @@ export {
 | 
			
		|||
  PreferencesService,
 | 
			
		||||
  HumbugService,
 | 
			
		||||
  InvitesService,
 | 
			
		||||
  UserService,
 | 
			
		||||
  SubscriptionsService,
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +0,0 @@
 | 
			
		|||
import { http } from "../utils";
 | 
			
		||||
 | 
			
		||||
const AUTH_URL = process.env.NEXT_PUBLIC_SIMIOTICS_AUTH_URL;
 | 
			
		||||
 | 
			
		||||
export const findUser = (query) => {
 | 
			
		||||
  return http({
 | 
			
		||||
    method: "GET",
 | 
			
		||||
    url: `${AUTH_URL}/user/find?${query}`,
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue