Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async (dispatch) => {
try {
const fetchClient = new FetchClient()
fetchClient.setAuthToken(token)
// This endpoint doesn't return anything upon success (result is always null)
// eslint-disable-next-line no-unused-vars
const { result, error } = await fetchClient.delete({
url: '/auth/logout'
})
if (!error) {
dispatch(setAccessToken(null))
dispatch(setUser(null))
await firebase.auth().signOut()
return
}
console.error(error)
return { result: null, error }
} catch (error) {
logError(dispatch, error)
return error
}
}
}
verificationUserEmail() {
firebase.auth().currentUser.sendEmailVerification().then(() => {
// Email sent.
}, (error) => {
// An error happened.
});
}
signUserInTwitter ({commit}) {
commit('setLoading', true)
commit('clearError')
firebase.auth().signInWithPopup(new firebase.auth.TwitterAuthProvider())
.then(
user => {
commit('setLoading', false)
const newUser = {
id: user.uid,
name: user.displayName,
email: user.email,
photoUrl: user.photoURL
}
commit('setUser', newUser)
}
)
.catch(
error => {
commit('setLoading', false)
commit('setError', error)
state('small', style({
transform: 'scale(1)',
})),
state('large', style({
transform: 'scale(2)',
})),
transition('small <=> large', animate('500ms ease-in', keyframes([
style({opacity: 0, transform: 'translateY(-80%)', offset: 0}),
style({opacity: 1, transform: 'translateY(25px)', offset: 1})
]))),
]),
]
})
export class ProfileComponent implements OnInit {
public uid = firebase.auth().currentUser.uid;
public fullImagePath: string = '/assets/img/mb-bg-04.png';
public profileTitle: string = 'My profile';
public displayName: string = 'Your username';
public bio: any = 'Your bio';
public state: string = 'small';
constructor(
private userService: UserService,
private alertService: AlertService) {}
public ngOnInit(): Promise {
return firebase.database().ref().child('users/' + this.uid).once('value').then((snap) => {
this.displayName = snap.val().displayName,
this.bio = snap.val().bio
});
handleLogout () {
firebase.auth().signOut()
.then(result => console.log(`${result.user.email} ha iniciado sesión`))
.catch(error => console.log(`Error ${error.code}: ${error.message}`));
}
authService.signOut().subscribe(() => {
expect(firebase.auth().signOut).toHaveBeenCalled();
done();
});
});
export const logIn = (email, password) => () =>
firebase.auth().signInWithEmailAndPassword(email, password);
export const logOut = () => () => firebase.auth().signOut();
(result) => {
if (result.user) {
const user = createUser(result.user)
if (result.credential) {
user.accessToken = result.credential.accessToken
}
resolve({
user: firebase.auth().currentUser ? user : null,
isRedirected: true
})
} else {
const unsubscribe = firebase.auth().onAuthStateChanged(user => {
unsubscribe()
resolve({
user: user ? createUser(user) : null,
isRedirected: false
})
})
}
}, (error) => {
reject(new FirebaseProviderError(error))
componentWillMount() {
const { router, dispatch } = this.props;
const { firebaseConfig } = this.context;
dispatch({ type: APP.SETUP });
firebase.initializeApp(firebaseConfig);
firebase
.auth()
.onAuthStateChanged(user => {
if (user) {
dispatch({
type: AUTH.AUTHENTICATED,
payload: {
uid: user.uid,
email: user.email,
photoURL: user.photoURL,
displayName: user.displayName,
isAnonymous: user.isAnonymous,
emailVerified: user.emailVerified,
},
});
if (location.pathname.startsWith(route('auth'))) {
created() {
var vm = this
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
vm.user = user;
vm.name = vm.user.displayName;
vm.email = vm.user.email;
vm.photo = vm.user.photoURL;
vm.userId = vm.user.uid;
}
});
},
methods: {