Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
7 changes: 7 additions & 0 deletions src/hooks/auth0-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
PasswordRealmOptions,
ExchangeNativeSocialOptions,
RevokeOptions,
ResetPasswordOptions,
} from '../types';

export interface Auth0ContextInterface<TUser extends User = User>
Expand Down Expand Up @@ -131,6 +132,11 @@ export interface Auth0ContextInterface<TUser extends User = User>
*Revokes an issued refresh token. See {@link Auth#revoke}
*/
revokeRefreshToken: (parameters: RevokeOptions) => Promise<void>;

/**
*Request an email with instructions to change password of a user {@link Auth#resetPassword}
*/
resetPassword: (parameters: ResetPasswordOptions) => Promise<void>;
}

export interface AuthState<TUser extends User = User> {
Expand Down Expand Up @@ -173,6 +179,7 @@ const initialContext = {
authorizeWithPasswordRealm: stub,
authorizeWithExchangeNativeSocial: stub,
revokeRefreshToken: stub,
resetPassword: stub,
};

const Auth0Context = createContext<Auth0ContextInterface>(initialContext);
Expand Down
16 changes: 16 additions & 0 deletions src/hooks/auth0-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
PasswordRealmOptions,
ExchangeNativeSocialOptions,
RevokeOptions,
ResetPasswordOptions,
} from '../types';
import { CustomJwtPayload } from '../internal-types';
import { convertUser } from '../utils/userConversion';
Expand Down Expand Up @@ -359,6 +360,19 @@ const Auth0Provider = ({
[client]
);

const resetPassword = useCallback(
async (parameters: ResetPasswordOptions) => {
try {
await client.auth.resetPassword(parameters);
return;
} catch (error) {
dispatch({ type: 'ERROR', error });
return;
}
},
[client]
);

const hasValidCredentials = useCallback(
async (minTtl: number = 0) => {
return await client.credentialsManager.hasValidCredentials(minTtl);
Expand Down Expand Up @@ -396,6 +410,7 @@ const Auth0Provider = ({
authorizeWithPasswordRealm,
authorizeWithExchangeNativeSocial,
revokeRefreshToken,
resetPassword,
}),
[
state,
Expand All @@ -416,6 +431,7 @@ const Auth0Provider = ({
authorizeWithPasswordRealm,
authorizeWithExchangeNativeSocial,
revokeRefreshToken,
resetPassword,
]
);

Expand Down